Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Closing down a connected network socket Message-ID: <9735@jpl-devvax.JPL.NASA.GOV> Date: 28 Sep 90 23:27:02 GMT References: <1990Sep28.214349.18443@uvaarpa.Virginia.EDU> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 20 In article <1990Sep28.214349.18443@uvaarpa.Virginia.EDU> worley@compass.com writes: : I'm trying to build a client that connects in sequence to several : different servers. In order to not have to call socket and bind : repeatedly, I want to just connect to each server and then do shutdown : to disconnect. However, I'm having trouble getting it to work -- no : value of the HOW parameter seems to leave the socket in a clean state : that can execute a further connect without error. : : I don't know what I'm doing wrong. Has anybody done this who can tell : me what the correct method is? After the first connect, the socket has a port number, even though you didn't assign one, and I imagine the system thinks that the port is still in use until it can get all it's handshaking done with the other end. If so, try rebinding with a port of 0 and let the system pick a fresh outgoing port. If that doesn't work, try setting the socket option SO_REUSEADDR. Of course, it's possible I just screwed up somewhere. I've never used shutdown, actually. Larry