ArrayList listenList = new ArrayList();
listenList.Add(socket0);
listenList.Add(socket1);
listenList.Add(socket2);
ArrayList acceptList = new ArrayList();
acceptList.Add(socket3);
acceptList.Add(socket4);
acceptList.Add(socket5);
for( int i = 0; i < 3; i++ )
{
listenList[i] = new Socket(AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
((Socket)listenList[i]).Bind(new IPEndPoint(ipAddress, 11000 + i));
((Socket)listenList[i]).Listen(10);
}
// Only the sockets that contain a connection request
// will remain in listenList after Select returns.
Socket.Select(listenList, null, null, 1000);
for( int i = 0; i < listenList.Count; i++ )
{
acceptList[i] = ((Socket)listenList[i]).Accept();
}
要求
平台: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 系列, .NET Framework 精简版 - Windows CE .NET, 公共语言基础结构 (CLI) 标准