C# Socket异步通讯客户端之主程序: # public static int Main(String[] args) # { # # IPAddress ipAddress = IPAddress.Parse("192.168.1.104"); # int port = 20000; # IPEndPoint remoteEP = new IPEndPoint(ipAddress, port); # # // 生成一个TCP/IP socket. # Socket client = new Socket(AddressFamily.InterNetwork, # SocketType.Stream, ProtocolType.Tcp); # # // 与目标终端连接. # client.BeginConnect(remoteEP, # new AsyncCallback(ConnectCallback), client); # //等待,直到连接程序完成。在ConnectCallback中适当位置有connecDone.Set()语句 # connectDone.WaitOne(); # # // 发送数据到远程终端. # Send(client, "This is a test<EOF>"); # sendDone.WaitOne(); # # // 接收返回数据. # Receive(client); # receiveDone.WaitOne(); # # // Write the response to the console. # Console.WriteLine("Response received : {0}", response); # # // Release the socket. # client.Shutdown(SocketShutdown.Both); # client.Close(); # # return 0; # # public static int Mai 你的当前访问异常,请进行认证后继续阅读剩余内容。 提交