httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Life is hard, and then you die." <>
Subject Re: bind-connect in rfc1413.c
Date Thu, 02 Sep 1999 15:29:06 GMT

> Okay, I must be missing something.  I am trying to put some of the APR
> stuff into Apache 2.0, and I came across a case I wasn't prepared for when
> I wrote APR.
> In rfc1413.c, line 130:
> bind (sock, &our_query_sin, sizeof(struct sockaddr_in));
> On line 141:
> connect(sock, &rmt_query_sin, sizeof(struct sockaddr_in));
> It's the same socket in both calls, and it's a SOCK_STREAM socket.  Why
> are we binding and then connecting?  There are comments about trying to
> bind both local and remote ends to the same IP addr.  But this doesn't
> make any sense to me.  Dean seems to have a comment at the beginning of
> the function saying something is broken, but he isn't specific about what
> it is.
> In all of the TCP/IP network programming I have done, bind is done on the
> server side, and connect is done on the client side.  In fact, most of my
> books say the bind is really unnecessary.
> So, what am I missing?

The bind() is useful and necessary if you have a multihomed machine and
you want to control the address the packets are being sent from.
Otherwise the connect will bind to some default address. But I don't
know if this is necessary in rfc1413.c or not.



View raw message