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); } }