Re: how to tell a socket to use a specific interface...
Re: how to tell a socket to use a specific interface...
- Subject: Re: how to tell a socket to use a specific interface...
- From: Igor Garnov <email@hidden>
- Date: Sun, 22 May 2005 22:22:48 +0400
Hello everybody
Perhaps you need to spend some time with a book like W. Richard
Stevens' "Unix Network Programming, v1, 2ed (or 3ed)". First, what do
you mean "code ... gets autorouted"? Second, bind() has *no* effect
on routing. Routing is dictated by the destination address of the
packet you want to be sent.
The comment may be old, but just in case: you *can't* bind to an
interface.
But then could somebody imagine a situation when calling 'bind' before
'connect' makes some sense? I'm asking because I thought that if I call
'bind' before 'connect'ing, the outgoing packets will have the IP
address in their headers, to which I have 'bound' the socket. If I
don't 'bind' the socket that I'll use to connect to a server, the
kernel will automatically 'bind' this socket for me.
So, in my opinion 'bind'ing a socket before 'connect'ing it to a remote
server is only worth it when the remote server has some kind of
restriction on the address of incoming connections. Then if I don't
'bind' the socket to the IP address which I know is trustworthy from
the server's point of view, my kernel may bind this socket to another
IP, and the remote server will refuse the connection.
Could someone comment on this?
Regards,
Igor
_______________________________________________
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