• 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: (correction) how to tell a socket to use a specific interface...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (correction) how to tell a socket to use a specific interface...


  • Subject: Re: (correction) how to tell a socket to use a specific interface...
  • From: Philip George <email@hidden>
  • Date: Fri, 20 May 2005 14:39:19 -0500

i had a typo in the code i sent. correction below ('int drval = 1' changed to 'int val = 1').

also, i didn't specify before that i'm talking about an outgoing connection. in other words, i use send() a few lines after what is shown here to send a web request and recv() to get the requested page. the catch being that i need to specify that the request be routed through a specific interface, not just any old interface (assuming that at runtime there are 2 or more available connections from the computer out to the internet).


CORRECTED CODE SNIPPET:

// setup local address stuff...

struct sockaddr_in LOCaddr;
LOCaddr.sin_family = AF_INET;
LOCaddr.sin_addr.s_addr = inet_addr(local_ip);


// set to true for SO_DONTROUTE...

int val = 1;


// bind to specific interface and then set SO_DONTROUTE...

if (bind(sockethandle, (struct sockaddr *)&LOCaddr, sizeof(LOCaddr))==0) {
setsockopt(sockethandle, SOL_SOCKET, SO_DONTROUTE, &val, sizeof(val));
}





thanks again.

- philip


_______________________________________________ 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: (correction) how to tell a socket to use a specific interface...
      • From: anna Smith <email@hidden>
References: 
 >how to tell a socket to use a specific interface... (From: Philip George <email@hidden>)

  • Prev by Date: how to tell a socket to use a specific interface...
  • Next by Date: Re: Getting the IP address of computer
  • Previous by thread: how to tell a socket to use a specific interface...
  • Next by thread: Re: (correction) how to tell a socket to use a specific interface...
  • Index(es):
    • Date
    • Thread