Click to See Complete Forum and Search --> : Bind socket to the interface


pupkin
June 20th, 2007, 11:45 AM
Hi,

I have following situation:
my Linux host has two interfaces eth0 (192.168.254.254) and eth1 (192.168.253.254). For the test purpose I want connect these two port with a cable and make some data exchange. For both the server and client socket I make bind(). The IP addresses seem to be assigned properly. When I start the test and lo interface is up everything runs successfully but not over the cable. When I make lo interface down I don't any connection. I also tried to set route for these hosts but with the same result. What am I doing wrong?

Thanks in advance

MikeAThon
June 20th, 2007, 01:14 PM
I might be wrong (easily, since I am not familiar with Linux), but I don't think that you can get it to work the way you want. At least in Windows, the TCP stack will notice that you are self-connecting, and will bypass the cable entirely, so that nothing will ever go out over the wire.

Mike

pupkin
July 5th, 2007, 03:34 AM
I have solved the problem by putting the interfaces in promiscuous mode and sending raw ethernet broadcast packet. If I unplug the cable I still can receive the packet but the RX bytes on the interface won't be incremented. So checking RX bytes (read /proc/net/dev) I can recognize if the communication was successfully gone over the cable.