UDP Server

M

Mohammad ---

Alright I've been trying to set up a UDP server for my "Game", the
"Client" is in python, but I want a ruby server. I tried some code from
the Ruby book, but I wasn't able to get it to work. If someone could
please help me out with starting the server. BTW: port is 5555
 
P

Paul Barry

Not sure what platform you are using, but ... if Linux, some of the
distros come with a pretty tight firewall setting by default ... your
traffic to port 5555 may be being discarded/blocked.

Just a thought.

The other thing that might help the network-savvy readers to help you is
if you post the code (or part of) you have written that's not working.

Regards.

Paul.
 
J

John Turner

Mohammad said:
Alright I've been trying to set up a UDP server for my "Game", the
"Client" is in python, but I want a ruby server. I tried some code from
the Ruby book, but I wasn't able to get it to work. If someone could
please help me out with starting the server. BTW: port is 5555

Code for just about the simplest of servers is below, should just print
out all requests coming in from your python client if it's sending it
correctly:

require 'socket'
serv = UDPSocket.open
serv.bind(nil, 5555) #first param is hostname, nil works fine.
loop{puts serv.recv(5555)}

If it doesn't work then you should probably test to make sure your
python client is actually sending things correctly.
 
M

Mohammad ---

John said:
Code for just about the simplest of servers is below, should just print
out all requests coming in from your python client if it's sending it
correctly:

require 'socket'
serv = UDPSocket.open
serv.bind(nil, 5555) #first param is hostname, nil works fine.
loop{puts serv.recv(5555)}

If it doesn't work then you should probably test to make sure your
python client is actually sending things correctly.

Thanks alot now I can get started on a server. :D also how would I get
the address also, the reasson why I decided to do the game in python
instead of ruby was beacause there is a libary called "PyGame" which is
just a another handler for open SDL(is that it? the graphics?) anyway is
there one for ruby there's still time for me to change the language
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top