Eric Monti
2008-Jul-15 23:04 UTC
[Eventmachine-talk] local source port/address bind()ing for TCP
Hi there, I''ve been digging around the code extensively and I can''t seem to find a way to bind EventMachine''s TCP client on a specified local port and interface. Am I missing something here? As a point of reference, this ruby snippet works just fine (and illustrates the basic idea): -snip- $ ruby << _EOF_ require ''socket'' sd = Socket.new( Socket::AF_INET, Socket::SOCK_STREAM, 0) sd.bind( Socket.pack_sockaddr_in( 9999, "127.0.0.1" ) ) sd.connect( Socket.pack_sockaddr_in( 8888, "127.0.0.1" ) ) sd.write("hi there\n") sd.close _EOF_ -/snip- -snip (Consider this the "Server" I want to talk to)- $ nc -v -l -p 8888 listening on [any] 8888 ... connect to [127.0.0.1] from localhost [127.0.0.1] 9999 hi there -/snip- In short, ''bind'' only really seems to get exposed by EventMachine for UDP datagram sockets. I need to do this sort of thing with TCP to speak a particular protocol through someone''s paranoid firewall. It''s also an option I''d really like to support in some generalized network testing tools I''m writing around evma. Regards, Eric Monti emonti at matasano.com -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2421 bytes Desc: not available URL: <http://rubyforge.org/pipermail/eventmachine-talk/attachments/20080716/955c7d07/attachment.bin>