Re: Networks and wireless etc
- From: "Eugene Gershnik" <gershnik@xxxxxxxxxxx>
- Date: Wed, 6 Jul 2005 01:40:39 -0700
Alun Jones [MSFT] wrote:
> "Eugene Gershnik" <gershnik@xxxxxxxxxxx> wrote in message
> news:uYD3juNfFHA.484@xxxxxxxxxxxxxxxxxxxxxxx
>> Alun Jones [MSFT] wrote:
Well I just made a simple test of my scenarios 1 and 2 on XP SP2. I am happy
to report that as far as I could determine we both were somewhat right and
somewhat wrong. ;-) (Disclaimer: my test may be wrong or I could do
something stupid. What follows is "as far as I could determine")
I tried various cases including the ones mentioned in my post and the end
result seems to be this:
When bind() assigns an interface that contradicts the routing table the
connect() always fails with WSAEHOSTUNREACH *regardless* of whether a good
route exist to the destination host. *No* SYN is sent on an interface
different from the one assigned by bind() and *no* SYN is sent on the bound
interface.
IOW neither my expectations nor yours were entirely correct
The only correct conslusion is what I said in one of my older posts "The way
I see it you need *both* to bind correctly and have a workable routing
table." (Of course we agree that the best thing is not to bind() at all)
That calms my worries about usability and security ("if I said use X than
use X or fail").
> Here's an article from December 2001 detailing IP routing for IPv4:
>
> http://www.microsoft.com/technet/community/columns/cableguy/cg1201.mspx
>
> The wrinkle comes in IPv6, where it acts more like you want:
>
> http://www.microsoft.com/technet/community/columns/cableguy/cg1002.mspx
These are nice articles which explain what I know pretty well i.e. how the
routing table works. What the first one doesn't mention and the second one
mentiones in a non-conclusive way (i.e. "interface assigned the source
address") is how Winsock level bind() interacts with routing.
I beleive that the following text from the second article applies both to
IPv4 and IPv6 on Winsock
"For a sending host, if the source address is specified by the sending
application, the only routes that are checked are those that apply to the
interface assigned the source address. For a sending host, if the source
address is not specified by the sending application, or for a forwarding
router, all the routes are checked"
> Note - this is one more reason why it's a bad idea to call bind()
> before calling connect().
Agreed. Still, very rarely you may want to force the client to talk only on
a given interface.
--
Eugene
http://www.gershnik.com
.
- References:
- Re: Networks and wireless etc
- From: Alun Jones [MSFT]
- Re: Networks and wireless etc
- Prev by Date: Re: LSP problem with other programs
- Next by Date: Re: using PortManager in RTC causes RTC_E_MEDIA_SESSION_NOT_EXIST
- Previous by thread: Re: Networks and wireless etc
- Next by thread: Listening socket problem
- Index(es):
Relevant Pages
|