epmd

David Gould dg@REDACTED
Wed May 31 02:52:28 CEST 2000


On Tue, May 30, 2000 at 06:14:29PM +0100, Richard Barrett wrote:
... 
> It turns out that Suse 6.2 Linux (as on _WIN32_) and possibly other 
> versions of Linux, take the SO_REUSEADDR socket option at face value. 
> In consequence, bind failure, when this socket option is used, is 
> inadequate as the sole determinant of whether epmd is already extant 
> in the system.
... 
> For reasons I have yet to determine, under Sun Solaris, an attempt to 
> bind to a given port by a second instance of my test scripts (see 
> below) does fail, even though the SO_REUSEADDR socket option has be 
> enabled. So, Solaris and Suse 6.2 Linux appear to interpret the 
> semantics of the SO_REUSEADDR socket option rather differently and 
> I've no opinion as to which is correct.
> 
> Incidentally, I explored this problem using some short Python 
> scripts, copies of which are given below. Thanks to those readers who 
> contributed a response to my original posting.

I tested with your scripts on SuSE 6.4

  (Linux archimedes 2.2.14 #1 Sat Mar 11 04:17:23 GMT 2000 i686 unknown)

and get the correct result I think:

      $ python so_reuseaddr_svr.py  &
      [1] 7644
      Server process pid=7644 starting with SO_REUSEADDR=1
      $ python so_reuseaddr_svr.py  &
      [2] 7645
      Server process pid=7645 starting with SO_REUSEADDR=1
      Traceback (innermost last):
        File "so_reuseaddr_svr.py", line 11, in ?
          s.bind(HOST, PORT)
      socket.error: (98, 'Address already in use')

-dg
 
> --------------------------------------------------------
> Experimental Python scripts are as follows.
> 
> server script enabling SO_REUSEADDR --------------------
> 
> from socket import *
> import os
> pid = os.getpid()
> HOST = ''
> PORT = 4369
> s = socket(AF_INET, SOCK_STREAM)
> s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
> reuse = s.getsockopt(SOL_SOCKET, SO_REUSEADDR)
> print "Server process pid=%d starting with SO_REUSEADDR=%d" % (pid, reuse)
> s.bind(HOST, PORT)
> s.listen(1)
> conn, addr = s.accept()
> s.close()
> print "Process %d connected to %s with SO_REUSEADDR=%d" % (pid, addr, reuse)
> while 1:
> 	data = conn.recv(1024)
> 	if not data: break
> 	data = data + (", returned by pid=%d" % pid)
> 	conn.send(data)
> conn.close()
> 
> server script not enabling SO_REUSEADDR --------------------
> 
> from socket import *
> import os
> pid = os.getpid()
> HOST = ''
> PORT = 4369
> s = socket(AF_INET, SOCK_STREAM)
> reuse = s.getsockopt(SOL_SOCKET, SO_REUSEADDR)
> print "Server process pid=%d starting with SO_REUSEADDR=%d" % (pid, reuse)
> s.bind(HOST, PORT)
> s.listen(1)
> conn, addr = s.accept()
> s.close()
> print "Process %d connected to %s with SO_REUSEADDR=%d" % (pid, addr, reuse)
> while 1:
> 	data = conn.recv(1024)
> 	if not data: break
> 	data = data + (", returned by pid=%d" % pid)
> 	conn.send(data)
> conn.close()
> 
> client script --------------------
> from socket import *
> import os
> pid = os.getpid()
> print "Client process pid=%d starting" % pid
> HOST = ''
> PORT = 4369
> s = socket(AF_INET, SOCK_STREAM)
> s.connect(HOST, PORT)
> s.send("Hello, world sent from pid=%d" % pid)
> data = s.recv(1024)
> s.close()
> print 'Received', `data`
> --------------------------------------------------------------

-- 
David Gould                                                 dg@REDACTED
SuSE, Inc.,  580 2cd St. #210,  Oakland, CA 94607          510.628.3380
C++ : an octopus made by nailing extra legs onto a dog



More information about the erlang-questions mailing list