N
Niklas Frykholm
The #recvfrom call in this code:
socket = UDPSocket.new
socket.bind(0, 12345)
loop {puts socket.recvfrom(1000)[0]}
Runs extremely slow on my ruby (ruby 1.8.2 (2004-07-29) [i386-cygwin]),
on the order of 2 seconds per call. I see similar problems have been
mentioned before:
http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/136959
http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/143448
but no solution or diagnostic was given in the replies.
If #recvfrom is changed to #recv, the code runs at the expected (fast)
speed, so I believe that the slow operation is the conversion of the IP
address returned by C's recvfrom() to a network name. Apparently, on a
(badly configured???) Windows network, this can be a really slow operation.
Is there a way of disabling this name lookup in the call to #recvfrom?
If not, maybe one could be added in a future version of ruby.
// Niklas
socket = UDPSocket.new
socket.bind(0, 12345)
loop {puts socket.recvfrom(1000)[0]}
Runs extremely slow on my ruby (ruby 1.8.2 (2004-07-29) [i386-cygwin]),
on the order of 2 seconds per call. I see similar problems have been
mentioned before:
http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/136959
http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/143448
but no solution or diagnostic was given in the replies.
If #recvfrom is changed to #recv, the code runs at the expected (fast)
speed, so I believe that the slow operation is the conversion of the IP
address returned by C's recvfrom() to a network name. Apparently, on a
(badly configured???) Windows network, this can be a really slow operation.
Is there a way of disabling this name lookup in the call to #recvfrom?
If not, maybe one could be added in a future version of ruby.
// Niklas