我正在尝试使用 C3 .net 中的套接字通过服务器发送 xml 显示以下错误:
请求的地址在其上下文中无效
说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详情:
System.Net.Sockets.SocketException: The requested address is not valid in its context
Source Error:
Line 38:
Line 39:
Line 40: sock.Bind(ipEnd);
Line 41: sock.Listen(100);
Line 42:
后面的代码:
IPEndPoint ipEnd = new IPEndPoint(IPAddress.Parse("172.16.0.32"),50001);/*the ip of the server*/
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
sock.Bind(ipEnd);
sock.Listen(100);
Socket clientsock = sock.Accept();
byte[] b = new byte[1024 * 10000];
int recsize = clientsock.Receive(b);
FileStream fileStream = new FileStream("PersonData.xml", FileMode.Create);
fileStream.Write(b, 0, recsize);
fileStream.Close();