Пример #1
0
        public override void Operation()
        {
            try
            {
                // Connect to the remote endpoint.
                Socketv4.BeginConnect(new IPEndPoint(IPAddress.Loopback, Config.Port),
                                      ConnectCallback, Socketv4);
                _connectDone.WaitOne();

                // Send test data to the remote device.
                Send(Socketv4, Message);
                _sendDone.WaitOne();

                // Receive the response from the remote device.
                Receive(Socketv4);
                _receiveDone.WaitOne();

                // Write the response to the console.
                //Console.WriteLine("Response received : {0}", response);

                // Release the socket.
                Socketv4.Shutdown(SocketShutdown.Both);
                Socketv4.Close();
            }
            catch (Exception e)
            {
                ErrorUtil.WriteError(e).GetAwaiter().GetResult();
            }
        }