开发者

How to bind two UdpClients to the same port?

My problem is that I have more than one instance of my class, while trying to listen the same port. I've found that I can do it (listen on the same port) with the code I found (using the "ReuseAddress"), however it only works with m开发者_StackOverflow中文版ulticast and broadcast packets, whilst I need unicast packets.

Anyone knows how I can make it work with unicast aswell?

Thanks.


Unfortunately, since UDP does not support the concept of a connection, it's usually not possible to bind multiple UDP sockets to the same local address:port pair. What you can do, however, is write your own wrapper around a single, shared UDP socket that figures out which client an incoming packet comes from, and routes it to the appropriate point within your own code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜