• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: how to tell a socket to use a specific interface...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to tell a socket to use a specific interface...


  • Subject: Re: how to tell a socket to use a specific interface...
  • From: Josh Graessley <email@hidden>
  • Date: Fri, 20 May 2005 14:51:59 -0700


SO_DONTROUTE probably isn't nearly as useful as you might imagine.

SO_DONTROUTE means don't go through a router. The stack will look for a network directly accessible on one of the interfaces. This requires an address in that network assigned to an interface. When SO_DONTROUTE is set, the packet won't be sent through a gateway and the stack won't check the routing table determine if there are additional locally accessible networks. Since the destination you were trying to reach is not local to either interface, both attempts fail.

Mac OS X's routing is based only on the destination address. When you don't set the SO_DONTROUTE option, the packet is sent based on the destination address. Even though you bound to an address on en0, if the route says go out interface en1 to get to the destination, that is where the stack will send the packet. Sometimes this just works. Other times, this gets tripped when ingress filtering is enabled and a router drops the packet because it has the wrong source address or the source address is a private address that needed to be translated by a NAT.

-josh

On May 20, 2005, at 2:34 PM, Philip George wrote:


On May 20, 2005, at 4:14 PM, Peter Lovell wrote:


So your code should first open a socket, then use the "bind"
call to specify a sending IP address (and therefore a sending interface),
and then start to send.



That's what I've got already. It's not working. Look at the code I provided.


To test the code, I have an airport connection to a network that can see the internet, and I have a cat5 connection to a dead network that cannot see the internet.

Specifying the airport interface should allow the web request to happen. Specifying the cat5 connection should not, because it cannot see the internet to make it to the web server.

When I test **without** the SO_DONTROUTE line, both connect. When specifying the dead cat5 connection, it re-routes thru the good airport connection and grabs the page, which is what I'm trying to avoid.

When I test **with** SO_DONTROUTE, neither will get the page.

Is there anything wrong with the code I provided? Do you need to see the send() and recv() lines too?

Thanks.

- Philip

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

  • Follow-Ups:
    • Re: how to tell a socket to use a specific interface...
      • From: Philip George <email@hidden>
References: 
 >how to tell a socket to use a specific interface... (From: Philip George <email@hidden>)
 >Re: how to tell a socket to use a specific interface... (From: "Peter Lovell" <email@hidden>)
 >Re: how to tell a socket to use a specific interface... (From: Philip George <email@hidden>)

  • Prev by Date: Re: how to tell a socket to use a specific interface...
  • Next by Date: Re: how to tell a socket to use a specific interface...
  • Previous by thread: Re: how to tell a socket to use a specific interface...
  • Next by thread: Re: how to tell a socket to use a specific interface...
  • Index(es):
    • Date
    • Thread