Created
November 30, 2012 13:01
-
-
Save javiermon/4175610 to your computer and use it in GitHub Desktop.
Echo simple server with gevent
This file contains 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
#!/usr/bin/env python | |
""" | |
A simple echo server | |
""" | |
import gevent | |
from gevent import monkey; | |
monkey.patch_socket() | |
import socket | |
host = '' | |
port = 50000 | |
backlog = 5 | |
size = 1024 | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.bind((host,port)) | |
s.listen(backlog) | |
while 1: | |
client, address = s.accept() | |
data = client.recv(size) | |
if data: | |
client.send(data) | |
client.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment