コード例 #1
0
ファイル: CommandSender.cs プロジェクト: Diaver/EFlogger
        private static void SendAnswer(string ipAddress, int port, byte[] messageBytes)
        {
            var client = new TcpClient();

            try
            {
                client.Connect(ipAddress, port);

                byte[]        messageBytesWithEof = CommandUtils.AddCommandLength(messageBytes);
                NetworkStream networkStream       = client.GetStream();
                networkStream.Write(messageBytesWithEof, 0, messageBytesWithEof.Length);
                networkStream.Close();
                client.Close();
            }
            catch (SocketException exception) //hide exception,
            {
                Trace.WriteLine(exception.Message + " " + exception.InnerException);
            }
        }