我一直在收到这个错误,我相信我将问题缩小到我在 64 位机器上使用 32 位侦听器。有没有办法让它在 64 位系统上运行?
18 Socket sListener;
...
34 permission = new SocketPermission(NetworkAccess.Accept, TransportType.Tcp, "", SocketPermission.AllPorts);
36 //Listening Socket object
37 sListener = null;
39 //Ensure the code has permission to access the Socket
40 permission.Demand();
42 IPHostEntry ipHost = Dns.GetHostEntry("");
43 IPAddress ipAddress = ipHost.AddressList[2];
44 ipEndPoint = new IPEndPoint(ipAddress, 4510);
46 sListener = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
...
71 sListener.Listen(10);
72
73 //Begins an asynchronous operation to accept an attempt
74 AsyncCallback aCallback = new AsyncCallback(AcceptCallback);
75 sListener.BeginAccept(aCallback, sListener);
我试图遵循这个相关问题中的代码,但它给了我错误:
运算符“==”不能应用于“System.Net.Sockets.AddressFamily”和“字符串”类型的操作数