C# 只能将套接字绑定到127.0.0.1

C# 只能将套接字绑定到127.0.0.1,c#,sockets,C#,Sockets,我现在在C#中使用套接字服务器,但我只能将其绑定到127.0.0.1。 但它必须绑定到我的VPS IP。即使我尝试绑定到我的hamachi IP,它也不起作用 我使用: ServerSocketSettings Settings = new ServerSocketSettings { MaxConnections = Config.ServerMaxConnections, NumOfSaeaForRec = Config.ServerMaxConnections, B

我现在在C#中使用套接字服务器,但我只能将其绑定到127.0.0.1。 但它必须绑定到我的VPS IP。即使我尝试绑定到我的hamachi IP,它也不起作用

我使用:

ServerSocketSettings Settings = new ServerSocketSettings
{
    MaxConnections = Config.ServerMaxConnections,
    NumOfSaeaForRec = Config.ServerMaxConnections,
    Backlog = 30,
    MaxSimultaneousAcceptOps = 15,
    BufferSize = 512,
    Endpoint = new IPEndPoint(IPAddress.Parse("25.168.77.190"), Config.ServerPort)
};

this._serverSocket = new ServerSocket(Settings);
那么我会:

this.ListenSocket = new Socket(this.Settings.Endpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
this.ListenSocket.Bind(this.Settings.Endpoint);
this.ListenSocket.Listen(this.Settings.Backlog);
this.Settings是上述代码的值。 当我运行它时,我得到:

请求的地址在其上下文中无效


我想知道为什么它不起作用。

如果要将服务的可用性限制在此网段,则应仅将侦听套接字绑定到特定接口

如果不需要,您只需将其绑定到任何ip地址即可

this.ListenSocket.Bind(new IPEndPoint(IPAddress.Any));