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

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

@qinqoushui

Description

@qinqoushui

在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);
...
}


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions