我需要创建一个Socket类的实例,但我不确定我应该解析什么参数来创建TCP套接字,
System.Net .Sockets .Socket s = new System.Net.Sockets.Socket
(//what are the parameters required in here ?")
答案 0 :(得分:2)
对于tcp:
Socket s = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
对于Udp:
Socket s = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp);
上面的代码示例显示您必须以任何方式实例化套接字