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.
精彩评论