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
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.