📜  c# socket 监听端口 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:21.184000             🧑  作者: Mango

代码示例1
IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());  
IPAddress ipAddress = ipHostInfo.AddressList[0];  
IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 11000);  

Socket listener = new Socket(ipAddress.AddressFamily,
    SocketType.Stream, ProtocolType.Tcp);
listener.Bind(localEndPoint);  
listener.Listen(100); // specifies how many pending connections to the 
// Socket are allowed before a server busy error is returned to the connecting 
//client.