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

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


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

How can I specify that a socket use a specific interface?

I thought it was bind() that did this, but it doesn't seem like that's what it's doing at all.

If I have an airport connection to one network and a cat5 connection to another, how can i tell my socket to use a specific one.

Here's the code i've got that isn't working (although I'm pretty sure the setsockopt() line is okay) :

// 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 drval = 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));
}



Now that I'm looking at this isolated code, it seems more and more obvious that bind() isn't what i want. Haha. Now that I think about it, I guess it's probably more likely related to the dns server called 'bind'.


In any case... what is it that I need to do here?

Thanks.

- 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: how to tell a socket to use a specific interface...
      • From: Bryan Christianson <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: Justin Walker <email@hidden>
    • Re: (correction) how to tell a socket to use a specific interface...
      • From: Philip George <email@hidden>
  • Prev by Date: Getting the IP address of computer
  • Next by Date: Re: (correction) how to tell a socket to use a specific interface...
  • Previous by thread: Re: Getting the IP address of computer
  • Next by thread: Re: (correction) how to tell a socket to use a specific interface...
  • Index(es):
    • Date
    • Thread