[TriLUG] C & sockets programming question

Michael Tharp gxti at partiallystapled.com
Wed Jul 27 18:04:04 EDT 2005


Brian Weaver wrote:

>You can get the remote address (getpeername(2)), but as to which
>interface (lo, eth0, eth1) the packet was received on... not sure
>there is any easy way.
>
>-Brian
>  
>
getsockname() is what you want, assuming you want the local interface name.
Then maybe do black magic with /sbin/route? There's probably a way to do 
it portably,
but I don't know it.

Michael Tharp



More information about the TriLUG mailing list