From: Brian Candler Date: 2010-07-14T06:01:37+09:00 Subject: Re: Programming TCP-protocol Server (MineCraft) 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. -- Posted via http://www.ruby-forum.com/.