how to tell a socket to use a specific interface...
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