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
On 10/15/06, Mohammad — [email protected] wrote:
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–
Posted via http://www.ruby-forum.com/.
require ‘socket’
u = UDPsocket.new
u.bind( “127.0.0.1”, 5555 )
while msg = u.recv(4096)
p msg
end
Francis C. wrote:
On 10/15/06, Mohammad — [email protected] wrote:
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
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.
Mohammad — wrote:
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.
http://www.google.com/search?q=rubygame
As for network library, check out EventMachine:
http://rubyforge.org/projects/eventmachine. It makes doing UDP/TCP
connections and communication quite easy and much, much faster than pure
Ruby can (written in C++).
Jason
John T. wrote:
Mohammad — wrote:
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 5555Code 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. 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