2
现在服务器端的套接字绑定192.168.1.69:9000,然后开始监听。客户端使用127.0.0.1:9000连接服务器。但失败。但是,它在客户端使用192.168.1.69:9000连接服务器时起作用。
客户端和服务器都在同一台计算机上运行。
我的问题是:它应该成功当客户端使用环回地址连接服务器,但失败。为什么?客户端无法访问C#中绑定环回地址的服务器
Server Code:
this.pro_ListenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
this.pro_ListenSocket.ReceiveBufferSize = this.pro_BufferSize;
this.pro_ListenSocket.SendBufferSize = this.pro_BufferSize;
try
{
this.pro_ListenSocket.Bind(new IPEndPoint(this.pro_ServerIP, this.pro_Port));
}
catch (SocketException socketError)
{
return false;
}
catch (Exception)
{
return false;
}
try
{
this.pro_OnRunning = true;
this.pro_ListenSocket.Listen(500);
this.StartToAcceptClient(this.pro_ListenSocket);
}
catch (Exception ex)
{
return false;
}