Created
February 5, 2011 19:10
-
-
Save taotetek/812693 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import eventlet | |
from eventlet.green import socket | |
import zmq | |
import sys | |
PORT=3001 | |
def read_socket(writer, reader): | |
line = reader.readline() | |
while line: | |
sys.stdout.write(line) | |
sys.stdout.flush() | |
writer.send(line) | |
line = reader.readline() | |
if __name__ == '__main__': | |
try: | |
server = eventlet.listen(('127.0.0.1', 7000)) | |
while True: | |
new_connection, address = server.accept() | |
new_zmq_context = zmq.Context() | |
new_zmq_push_socket = new_zmq_context.socket(zmq.PUSH) | |
new_zmq_push_socket.connect("tcp://127.0.0.1:5558") | |
eventlet.spawn_n(read_socket, new_zmq_push_socket, new_connection.makefile('r')) | |
except (KeyboardInterrupt, SystemExit): | |
print "bye" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment