• 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: bsd sockets + selecting network interface
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bsd sockets + selecting network interface


  • Subject: Re: bsd sockets + selecting network interface
  • From: james woodyatt <email@hidden>
  • Date: Mon, 15 Dec 2008 19:45:37 -0800

On Dec 15, 2008, at 18:00, Josh Graessley wrote:

[...] You can bind your socket to an IP address assigned to a specific interface and all traffic generated by that socket will have that source address, however that doesn't guarantee that the traffic will go out the interface that IP address is assigned to.

Not entirely true.

If you bind the socket to an IPV6_LINK_LOCAL scope address and set the sin6_scope_id field of the socket address to a non-zero interface index, then you *are* guaranteed that the traffic will go out the specified interface.

Of course, this is only useful for communicating with other IPV6_LINK_LOCAL scope nodes. If you want to constrain unicast communication to a global destination through a specific network interface, then the only way to do that is with source routing-- which has been deprecated for both IPv4 and IPv6 on account of security considerations, and which has been made non-functional by most Internet routers in the field today.

On Dec 15, 2008, at 19:25, Joe Lake wrote:

my program discovers a service on using bonjour and then sends udp packets to it using bsd sockets. I'm using both apple and bsd apis because the sockets stuff is old code I incorporated into the project to finish it under deadline.


now my client is running it on a machine with two active network interfaces. what appears to be happening is a service is discovered via bonjour over one interface, but when I try to send data to it my socket sends it out the wrong interface.

This might be an error with your client handling IPv6 socket addresses, i.e. you didn't set the sin6_scope_id field properly, or it might be an error caused by the server not being attached to the network where the client host's primary active interface is attached, while the server is advertising an IPv4 address in mDNS outside the client's configured subnet.


Both of the above are pretty common mistakes.


-- james woodyatt <email@hidden> member of technical staff, communications engineering


_______________________________________________ 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: bsd sockets + selecting network interface
      • From: Joe Lake <email@hidden>
References: 
 >bsd sockets + selecting network interface (From: Joe Lake <email@hidden>)
 >Re: bsd sockets + selecting network interface (From: Josh Graessley <email@hidden>)

  • Prev by Date: Re: bsd sockets + selecting network interface
  • Next by Date: NSURLConnection and FTP directory content?
  • Previous by thread: Re: bsd sockets + selecting network interface
  • Next by thread: Re: bsd sockets + selecting network interface
  • Index(es):
    • Date
    • Thread