# Game server query problems

**URL:** <https://www.ruby-forum.com/t/game-server-query-problems/160375>\
**Category:** Ruby\
**Created:** [February 15, 2009, 3:13pm UTC](https://www.ruby-forum.com/t/game-server-query-problems/160375 "2009-02-15T15:13:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Randy\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/74df32/32.png) [@Randy\_W](https://www.ruby-forum.com/u/Randy_W)\
**Post date:** [February 15, 2009, 3:13pm UTC](https://www.ruby-forum.com/t/game-server-query-problems/160375/1 "2009-02-15T15:13:44Z")

</div>

Hello,  
I’m relatively new to Ruby, so some of this is foreign, but despite  
trying  
for several hours I can’t seem to get this query to work.

My goal is to create a query that’s consistent with this (  
[Gamespy Protocol 2](http://www.int64.org/docs/gamestat-protocols/gamespy2.html))

Here’s the code I have so far:

require ‘socket’

message = [0xFE,0xFD,0x00,0x43,0x4F,0x52,0x59,0xFF,0xFF,0x00].pack(“c\*”)  
socket = UDPsocket.new  
socket.connect(‘64.34.186.176’, 29900)  
socket.send(message, 0)  
receive = socket.recvfrom(1400)  
puts receive

In return I should receive some data, but no matter how long I leave it  
running I never get a response from the server. Apparently I’m doing  
something wrong, but I can’t seem to figure out what I’m messing up.

Any assistance is appreciated!

---

<div class="post-metadata">

**Author:** ![Randy\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/74df32/32.png) [@Randy\_W](https://www.ruby-forum.com/u/Randy_W)\
**Post date:** [February 15, 2009, 5:22pm UTC](https://www.ruby-forum.com/t/game-server-query-problems/160375/2 "2009-02-15T17:22:14Z")

</div>

Randy,

On Sun, Feb 15, 2009 at 9:11 AM, Randy W [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> message = [0xFE,0xFD,0x00,0x43,0x4F,0x52,0x59,0xFF,0xFF,0x00].pack(“c\*”)  
> socket = UDPsocket.new  
> socket.connect(‘64.34.186.176’, 29900)  
> socket.send(message, 0)  
> receive = socket.recvfrom(1400)  
> puts receive

Try TCPSocket instead of using UDP.

---

<div class="post-metadata">

**Author:** ![Randy\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/74df32/32.png) [@Randy\_W](https://www.ruby-forum.com/u/Randy_W)\
**Post date:** [February 15, 2009, 9:50pm UTC](https://www.ruby-forum.com/t/game-server-query-problems/160375/3 "2009-02-15T21:50:09Z")

</div>

Randy W wrote:

> Hello,  
> I’m relatively new to Ruby, so some of this is foreign, but despite  
> trying  
> for several hours I can’t seem to get this query to work.
> 
> My goal is to create a query that’s consistent with this (  
> [Gamespy Protocol 2](http://www.int64.org/docs/gamestat-protocols/gamespy2.html))

Similar thread:  
[http://www.ruby-forum.com/topic/178437](http://www.ruby-forum.com/topic/178437)
