开发者

Udp socket communication on same port on a computer

开发者 https://www.devze.com 2023-01-17 09:13 出处:网络
I have 2 programs on the same computer, 开发者_开发百科communicating using udp socket. While program A running, I want to extract some information to program B. Using the SO_REUSEADDR socket option, I

I have 2 programs on the same computer, 开发者_开发百科communicating using udp socket. While program A running, I want to extract some information to program B. Using the SO_REUSEADDR socket option, I am able to bind 2 programs to the same port. However, when program A sent a message, program A itself, instead of B, received the message and display in console. I am wondering why the message isn't directed to B, is it because of 2 programs bound on the same port and the udp doesn't know which program to direct the message? Thanks in advance.


It is VERY bad idea to bind two programs to the same socket. Use Program B as a 'proxy' (tunnel everything from program A through it), and then you can read the communication.

0

精彩评论

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