Re: libperlwww problems (fwd) (and Hi y'all)
Jack Shirazi - BIU (js@bison.lif.icnet.uk)
Mon, 15 Aug 94 11:05:57 BST
> > BTW, one observation and one question about wwwhttp.pl:
> > The bind and all that hostname and $ThisSock stuff is not necessary,
> > (though it doesn't hurt).
>
> It isn't? I've seen it in all the perl clients I've looked at
> (though I'll readily admit that I have never looked at it carefully).
> Could you elaborate?
Yeah. Larry put it in his examples in the book. Everyone has used
those examples and edited them (thats where I first learned sockets).
The bind allocates the local socket an ip address/port address (thats
the "name" in the man page). If you give it a non-zero port, it tries
to bind to that port. A zero port and the system allocates a port to
the socket. Usually with the client connection, you don't care about
what port you want (actually I've never seen a client socket that needs
to know what port its on), so you give it a port of zero.
The thing is, the connect call allocates a local port/ip address if
the socket isn't bound. You need bind if you are trying to start
the server on its port, but for the client, it is unnecessary.