[TriLUG] C & sockets programming question

Tanner Lovelace clubjuggler at gmail.com
Wed Jul 27 16:33:35 EDT 2005


Are you asking for the interface on the remote side?  If so,
I believe that information is not sent.  If you're asking about the
interface information on the local side, I'm not sure you can get
that either. You could try getsockname or getsockopt, but I don't 
think that either do what you want.  You could probably get the
local IP address and through that, somehow, call out to 
ifconfig or something to get the local interface, but it would
be horribly non-portable.

Cheers,
Tanner

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)?
> 
> Thanks
> Charles Fischer
> 
> --
> TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ  : http://trilug.org/faq/
> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
> TriLUG PGP Keyring         : http://trilug.org/~chrish/trilug.asc
> 


-- 
Tanner Lovelace
clubjuggler at gmail dot com
http://wtl.wayfarer.org/
http://www.freeiPods.com/?r=8127171
(fieldless) In fess two roundels in pale, a billet fesswise and an
increscent, all sable.



More information about the TriLUG mailing list