Skip to content
This repository has been archived by the owner on Feb 25, 2020. It is now read-only.

UdpClientListener中监听强制使用了127.0.0.1,不适用于多网卡环境 #56

Open
qinqoushui opened this issue Feb 15, 2020 · 0 comments

Comments

@qinqoushui
Copy link

在UdpClientListener中

 public UdpClientListener(ServerBuilderOptions options,
            ILogger<UdpClientListener> logger,
            IServerPacketProcessor serverPacketProcessor,
            IServerInformation serverInformation)
        {
            this.options = options;
            this.logger = logger;
            this.serverPacketProcessor = serverPacketProcessor;
            this.serverInformation = serverInformation;

            endPointPool = new ObjectPool<EndPoint>(this.options.UdpSocketObjectPoolSize);

            for (var i = 0; i < endPointPool.Capacity; i++)
                //endPointPool.Push(new IPEndPoint(IPAddress.Loopback, this.options.UdpPort));
                endPointPool.Push(new IPEndPoint(BindIPAddress, this.options.UdpPort));
        }
 public void Listen()
        {
            client = new UdpClient();
            client.ExclusiveAddressUse = false;
            client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
            
            //临时处理,后续使用option传入网卡地址
            //endPoint = new IPEndPoint(IPAddress.Loopback, options.UdpPort);
            endPoint = new IPEndPoint(BindIPAddress, options.UdpPort);
            client.Client.Bind(endPoint);
...
}


Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant