Path: utzoo!utgpu!watserv1!watmath!att!news.cs.indiana.edu!cica!sol.ctr.columbia.edu!emory!hubcap!gatech!ncar!elroy.jpl.nasa.gov!usc!apple!sun-barr!lll-winken!lll-crg.llnl.gov!booloo From: booloo@lll-crg.llnl.gov (Mark Boolootian) Newsgroups: comp.protocols.tcp-ip Subject: Re: reuse of addresses when calling bind() Message-ID: <87047@lll-winken.LLNL.GOV> Date: 30 Nov 90 23:13:35 GMT References: <86984@lll-winken.LLNL.GOV> <1990Nov30.202155.8253@bwdls61.bnr.ca> Sender: usenet@lll-winken.LLNL.GOV Organization: Lawrence Livermore National Laboratory Lines: 32 Nntp-Posting-Host: lll-crg.llnl.gov In article <1990Nov30.202155.8253@bwdls61.bnr.ca> pww@bnr.ca (Peter Whittaker) writes: >In article <86984@lll-winken.LLNL.GOV> booloo@lll-crg.llnl.gov (Mark Boolootian) writes: >>If you setsockopt() with SO_REUSEADDR, as I understand it, you should be able >>to issue a bind() for a ip/port address that is already in use. However, it >>appears that it is still possible for bind() to return the error EADDRINUSE > > >First, the original socket must have set SO_REUSEADDR - you cannot set it >retroactively. This is the case. Each socket wishing to bind to the same port number must issue a setsockopt() for SO_REUSEADDR. > >Second, two independent processes cannot bind to the same port no matter >what options are set. SO_REUSEADDR allows the same process, or children of >that process, to bind to same port (this is how ftp works: one server binds >its children to the same port, so all data flows from the same port). > This certainly isn't true. The FTP server always binds to local port 20 for data connections. The uniqueness of the connection must be guaranteed by the client's selection of a remote port. Since it is possible for there to be multiple instances of the ftp server running at one time, it is necessary to set the data socket with the SO_REUSEADDR option. This issue is talked about in the Unix Programmer's Manual on page 8-31 (PS1). Unfortunately, I still don't see how this particular error can occur once the socket has been correctly setsockopt()'ed. Thanks for the reply but I'm still confused. mb Brought to you by Super Global Mega Corp .com