[erlang-questions] clarify: SO_REUSEADDR under darwin?
Paul Mineiro
paul-trapexit@REDACTED
Thu Nov 8 05:25:49 CET 2007
hi.
i've attached a very short erlang program which tries to open two udp
ports with reuseaddr option. it works under linux but fails under darwin.
is this a known problem?
i can see the following in the ktrace:
--------
% ktrace -id -t c erl -eval 'test:test ()' -noshell -noinput -s init stop
--------
the kdump.out contains:
--------
28042 beam CALL socket(0x2,0x2,0x11)
28042 beam RET socket 9
28042 beam CALL fcntl(0x9,0x3,0)
28042 beam RET fcntl 2
28042 beam CALL fcntl(0x9,0x4,0x6)
28042 beam RET fcntl 0
28042 beam CALL setsockopt(0x9,0xffff,0x1002,0xbfffe1fc,0x4)
28042 beam RET setsockopt 0
28042 beam CALL setsockopt(0x9,0xffff,0x4,0xbfffe1fc,0x4)
28042 beam RET setsockopt 0
28042 beam CALL bind(0x9,0xbfffe0e0,0x10)
28042 beam RET bind -1 errno 48 Address already in use
--------
setsockopt(0x9,0xffff,0x4,0xbfffe1fc,0x4) looks right:
--------
% grep -e SO_REUSEADDR -e SOL_SOCKET /usr/include/sys/socket.h
#define SO_REUSEADDR 0x0004 /* allow local address reuse */
#define SOL_SOCKET 0xffff /* options for socket level */
--------
the only thing i can't verify is that 0xbfffe1fc is a pointer to one.
thanks,
-- p
% dpkg -s erlang-otp | grep Version
Version: 11b-5-1
% erl -version
Erlang (ASYNC_THREADS) (BEAM) emulator version 5.5.5
Optimism is an essential ingredient of innovation. How else can the
individual favor change over security?
-- Robert Noyce
-------------- next part --------------
-module (test).
-compile (export_all).
test () ->
Port = 4545,
{ ok, Socket } = gen_udp:open (Port,
[ { reuseaddr, true } ]),
{ ok, SocketTwo } = gen_udp:open (Port,
[ { reuseaddr, true } ]),
{ Socket, SocketTwo }.
More information about the erlang-questions
mailing list