c#(Socket)异步套接字代码示例

2019-12-26 11:15:51于海丽

public static ManualResetEvent allDone = new ManualResetEvent(false); 
public AsynchronousSocketListener() { 

public static void StartListening() { 
// Data buffer for incoming data. 
byte[] bytes = new Byte[1024]; 
// Establish the local endpoint for the socket. 
// The DNS name of the computer 
// running the listener is "host.contoso.com". 
IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName()); 
IPAddress ipAddress = ipHostInfo.AddressList[0]; 
IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 11000); 
// Create a TCP/IP socket.