Programming TCP-protocol Server (MineCraft)

There’s this game called Minecraft (http://www.minecraft.net/)

Read this site first:

What I want to do is to create a custom Minecraft Server in Ruby. There
are several in other languages:

But I’d like to make it in mine.

Basically all the server has to do is to

(Initialization):
Send it’s name, max players, ip and port to the server
(www.minecraft.net/heartbeat.jsp)

E.g:
(port=25565&max=32&name=name&public=True&version=7&salt=wo6kVAHjxoJcInKx&users=0)

And then receive each client and… do stuff <<- I can figure that out
on my own.

But the crucial thing I DON’T know is how to SEND TCP packets and DECODE
them after receiving them. May someone give me a pointer?

Zsdfhdfgasdf Gsfgsdgsdgsd wrote:

What I want to do is to create a custom Minecraft Server in Ruby.

If your server wants to accept incoming TCP connections from clients,
then you can use TCPServer and Socket#accept. gserver.rb in the standard
library wraps this all up for you. Read the source code for
documentation. It’s likely installed in your system somewhere like
/usr/lib/ruby/1.8/gserver.rb

See also the chapter “Network and Web Libraries” in Programming Ruby:
http://www.ruby-doc.org/docs/ProgrammingRuby/

But the crucial thing I DON’T know is how to SEND TCP packets and DECODE
them after receiving them. May someone give me a pointer?

Once you’ve got an open socket, you can just use gets() or read(n) to
get data (the first reads up to a newline, the second reads n bytes),
and puts() or write() to send data.

Note that each client will be handled in a separate thread, which means
you may need to be careful about thread-safety if you are working with a
shared data structure.

HTH,

Brian.

Brian.

Thank you alot. I have begun writing the pseudocode and such.