Getting Started

Installing Ratchet is extremely simple. You need gevent (which requires libevent & greenlets) and optionally Mercurial. Here's how in Ubuntu:
/home/tom# apt-get libevent-dev python-dev mercurial

/home/tom# easy_install greenlet

/home/tom# easy_install gevent

/home/tom# hg clone http://hg.errant.me.uk/ratchet

/home/tom# cd ratchet && python server.py
Starting RatchetMQ.... ....Ready!
By default RatchetMQ uses port 1146, but you can specify this on the command line using the -p flag:
/home/tom/ratchet# python server.py -p 1234
Starting RatchetMQ.... ....Ready!

Example Client

RatchetMQ also comes with a basic command line client for testing the server. It creates a queue, send a simple message and recieve it back:
/home/tom/ratchet# python client.py
Enter Message: Hello World
Creating Queue "Test"
Checking Queue Size: 0
Sending Message...
Checking Queue Size: 1
Recieving Message: Hello World
Enter Message:
(note that you can specify a non-default port in the same way as the server)

Here is the client code:
""" 
	Ratchet example client 
""" 
from ratchet import queue,message 
import ratchet.api as api 
 
port = api.getOpts() 
 
cn = api.connect(("0.0.0.0",port)) 
cn.announce("TEST-CLIENT") 
test = message.Message() 
 
while 1: 
	test["content"] = raw_input("Enter Message:") 
 
	print 'Creating Queue "Test"' 
	cn.open_queue("Test",0) 
	print 'Checking Queue Size:',cn.size_queue("Test") 
	print 'Sending Message...' 
	cn.send_message("EXAMPLE",test) 
	print 'Checking Queue Size:',cn.size_queue("Test") 
	print 'Recieving Message:',cn.recieve_message("EXAMPLE")