views:

20

answers:

1

Hi,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.

+2  A: 

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.

Yossarian
Sorry but how should I do that in C?
Darren