Re: Which network interface is being used??? (CFNetwork question)
Re: Which network interface is being used??? (CFNetwork question)
- Subject: Re: Which network interface is being used??? (CFNetwork question)
- From: "Peter Sichel" <email@hidden>
- Date: Tue, 14 Mar 2006 09:11:09 -0500
On 3/13/06, John Turnipseed wrote:
>It is a TCP connection created using the CFNetwork HTTP request
>calls. Thus far I haven't been able to find a way from a CFReadStream
>back to the IP address of the socket it's using.
If you can get your hands on the actual socket, you can use the
BSD functions getsockname() or getpeername() to get the protocol
address of the corresponding endpoints.
>Basically I'm just trying to report if there are multiple
>connections, which one is getting used. Ethernet, Airport, Modem, etc..
When you connect to a remote peer, the kernel will fill in the
appropriate local address to use based on the corresponding
network port (Ethernet, AirPort, etc). You can get this address
from the socket and then use the System Configuration Framework
to walk the list of configured interfaces and see which physical
port it corresponds to.
The only time this might not provide the right answer is if a host
on a locally attached LAN connects to an IP address on a different
physical port. Since Mac OS X uses a weak end system model, the
connection will still be accepted even though it arrived on a
different interface from the endpoint it is connecting too.
This case is so rare, you can probably ignore it. Alternatively,
you could get the peer IP address and use a routing socket to
see how the connection is routed (as previously suggested).
Kind Regards,
- Peter Sichel
Sustainable Softworks
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden