I am having a peculiar problem with UDP in windows. A simple test that
runs under linux fails in windows. Below are two scripts one for a
server and one for a client. The server starts by waiting for a packet
and then when it gets on it sends a response. The client starts by
sending a packet and waiting for a response.
On Linux the server prints the frame received and and waits for the next
one. The client prints the frame it received back from the server and exits.
On Windows, if the bind call is included, then the first packet never
gets sent by the client. If the bind call is ommitted, then the recvfrom
client.rb:12:in `recvfrom’: The network is busy.- recvfrom(2) (Errno::E054)
If the bind call is added back in after the connect call, then bind
client.rb:11:in `bind’: Invalid argument - bind(2) (Errno::EINVAL)
Any ideas on this one?
The select on the client does succeed so that it knows there is
something to receive. It just can’t get its hands on it ;-(
ruby 1.8.0 (2003-08-04) [i386-mswin32]
– Client.rb -------------------------
socket = UDPSocket.open
socket.connect(“192.168.4.80”, 1600) # FIXME get port from send page
if select([socket], nil, nil, 3) then
– Server.rb -------------------------
address = ARGV.shift or raise "ip address needed"
server = UDPSocket.open