From: Bill Kelly Date: 2004-05-12T07:36:31+09:00 Subject: Re: UDP socket Hi, From: "PeeF" > Hello. > > I'm looking for the source code of any existing and running program whitch > makes use of UDP Sockets. > Please could you help me to find some? I use this to send commands (status and rcon) to Quake 2 servers: 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 quake's leading 0xffffffff end rescue IOError, SystemCallError ensure sock.close if sock end resp end Hope this helps, Regards, Bill