[TriLUG] C & sockets programming question
rick.denatale at gmail.com
Wed Jul 27 16:32:46 EDT 2005
On 7/27/05, Charles Fischer <fischer at 4pi.com> wrote:
> I am patching a C program that opens a TCP/IP socket and listens. When
> "accept" returns a connecting socket, the program calls a read routine that
> does some checking. It would be nice if this read routine knew the
> interface's name (ie, lo, eth0 or eth1). Does anybody know how to get the
> interface's name from the socket ID (file ID)?
You might try getsockopt to see if the SO_BINDTODEVICE option is set.
In general though I don't think that tcp sockets are normally bound to
a particular device/interface.
More information about the TriLUG