I''m wondering how one goes about determining what port was actually
chosen if you start a server with port 0 using EventMachine. Or what
is the best way to make a server listen to a random, unused port above
1024 and determine immediately after setting up the server what port the
connection is actually using. There doesn''t seem to be any
documented way to do this in the present EventMachine API. However,
while poking around I managed to stumble across a completely
undocumented EventMachine.get_sockname method while looking at the
methods available in the EventMachine module itself, and it appears to
give me the information I need:
s = EventMachine::start_server("0.0.0.0", 0, MyProtocolModule) do
|conn|
...
end
addr = Socket.unpack_sockaddr_in(EventMachine.get_sockname(r))
If this is undocumented, I don''t think I can safely rely on this method
being available come the next version of EventMachine. So what would
be the canonical way to do this?
--
You know evolution did not just end with us growing thumbs. You see, the
reason why things are so messed up right now is because we are
undergoing evolution. The reason why our institutions are crumbling is
because they''re no longer relevant. Yes, they are no longer relevant.
http://stormwyrm.blogspot.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL:
<http://rubyforge.org/pipermail/eventmachine-talk/attachments/20090123/33646a90/attachment.bin>