UDP Socket Problem under Windows

Hi all,

as I’d read out of previous Messages other people already had the same
error in 1.6.7 W32. Is there a work-around, Bugfix available?

Script:

require “socket”

$address = “217.10.140.222”
$port = 12203
$command = “\xff\xff\xff\xff\x02getstatus\n”

sock = UDPSocket.open
sock.connect($address, $port)
sock.send($command,0)
$result = sock.recvfrom(10,0)
puts $result

causes:
rcon.rb:10:in `recvfrom’: Eine Nachricht, die ³ber einen
Datagrammsocket gesende
t wurde, war f³r den internen Nachrichtenpuffer oder ein anderes
Netzwerklimit z
u gro¯, oder der Puffer f³r den Datagrammempfang war f³r das Datagramm
zu klein.

  • “recvfrom(2)” (Errno::E10040)
    from rcon.rb:10

in English this would be:
Datagram-Buffer to small or Message to big

Any Ideas?

Thx!

responding to my own Message, uhh…

just checked out ruby 1.7.3 (2002-10-12) [i386-mswin32].
UDP Bug still there, seems I am lost?!

Hi,

as I’d read out of previous Messages other people already had the same
error in 1.6.7 W32. Is there a work-around, Bugfix available?

The following code is working reliably for me in 1.6.6 mswin32,
and (I think!!!) 1.6.7 mswin32. (Unfortunately the machine
running 1.6.7 went down last night and I can’t prove it has 1.6.7,
but I’m pretty sure it does, I installed it a couple days ago.)

Anyway for what it’s worth here’s the code. I notice there are
a couple differences which may or may not be relevant in comparison
to your example. (I’m not doing connect. I am doing select…)

UDP_RECV_TIMEOUT = 3 # seconds

def q2cmd(str)
resp, sock = nil, nil
begin
cmd = “\377\377\377\377#{str}\0”
sock = UDPSocket.open
sock.send(cmd, 0, @server_addr, @server_port)
resp = if select([sock], nil, nil, UDP_RECV_TIMEOUT)
sock.recvfrom(65536)
end
if resp
resp[0] = resp[0][4…-1] # trim leading 0xffffffff
end
rescue IOError, SystemCallError
ensure
sock.close if sock
end
resp
end

Script:

require “socket”

$address = “217.10.140.222”
$port = 12203
$command = “\xff\xff\xff\xff\x02getstatus\n”

sock = UDPSocket.open
sock.connect($address, $port)
sock.send($command,0)
$result = sock.recvfrom(10,0)
puts $result

Hope this helps,

Bill

P.S. What version of quake is yours for?

Anyway for what it’s worth here’s the code. I notice there are
a couple differences which may or may not be relevant in comparison
to your example. (I’m not doing connect. I am doing select…)

Yes that could be a Way. Anyhow under Linux it worked fine :slight_smile:

Hope this helps,

LOL hope so too. Gonna try it later tonight. Thx!

P.S. What version of quake is yours for?

Not Quake, but Medal of Honour

···

On Fri, 22 Nov 2002 01:41:57 +0900, “Bill Kelly” billk@cts.com wrote: