# Problem of UDPSocket on Windows

**URL:** <https://www.ruby-forum.com/t/problem-of-udpsocket-on-windows/154305>\
**Category:** Ruby\
**Created:** [November 27, 2008, 2:48pm UTC](https://www.ruby-forum.com/t/problem-of-udpsocket-on-windows/154305 "2008-11-27T14:48:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 27, 2008, 2:48pm UTC](https://www.ruby-forum.com/t/problem-of-udpsocket-on-windows/154305/1 "2008-11-27T14:48:22Z")

</div>

Hi, All:

I beg for your helps, my trouble as follow:

Background:  
Use UDP socket to implement an C/S module, Client send messages and  
Server  
receive these messages and print them.Client run

on Linux(RHEL 5.1) and Server run on Windows(XP).Thetwo computers are in  
LAN.

Problem:  
When client send a message,the server will receive this message after  
4-5  
seconds passed.It is a terrible delay!

Is there someone could tell me why? Is it a limitation on ruby  
UDPSocket(for  
Windows)?

PS:  
When the Server run on linux and the Client run on windows, the server  
can  
receive messages immediately.  
I tried to use C++ and Python to implement the Server, and it can  
receive  
messages immediately too.

server.rb:

require ‘socket’

socket = UDPSocket.new  
socket.bind(“192.168.1.101”,6321)  
loop do  
msg,sender = socket.recvfrom(1024)  
p msg  
end

client.rb:

require ‘socket’

socket = UDPSocket.new  
port = 6321  
host = “192.168.1.101”  
socket.send(ARGV[0],0,host,port)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 27, 2008, 7:48pm UTC](https://www.ruby-forum.com/t/problem-of-udpsocket-on-windows/154305/2 "2008-11-27T19:48:22Z")

</div>

Lee youser wrote:

> Problem:  
> When client send a message,the server will receive this message after 4-5  
> seconds passed.It is a terrible delay!

Try putting this at the top of your windows code:

Socket.do\_not\_reverse\_lookup = true

If that helps, then the problem has something to do with delay in DNS  
lookup, converting numerical to symbolic addresses.

Just a guess 🙂

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 28, 2008, 2:54pm UTC](https://www.ruby-forum.com/t/problem-of-udpsocket-on-windows/154305/3 "2008-11-28T14:54:12Z")

</div>

Joel :

> Try putting this at the top of your windows code:
> 
> Socket.do\_not\_reverse\_lookup = true

Thanks a lot 🙂
