32 |
from select import * |
from select import * |
33 |
from string import * |
from string import * |
34 |
|
|
35 |
class Connection: |
class Connection(object): |
36 |
"""An accepted connection. |
"""An accepted connection. |
37 |
|
|
38 |
It allows to send and receive lines of text messages from a client. |
It allows to send and receive lines of text messages from a client. |
253 |
self.dataqueue = "" |
self.dataqueue = "" |
254 |
|
|
255 |
|
|
256 |
class ConnectionHandler: |
class ConnectionHandler(object): |
257 |
"""A server that listens to a TCP port and accepts connection |
"""A server that listens to a TCP port and accepts connection |
258 |
requests from clients. |
requests from clients. |
259 |
|
|
346 |
|
|
347 |
clients = [] |
clients = [] |
348 |
|
|
349 |
class Client: |
class Client(object): |
350 |
def data_received(self, conn): |
def data_received(self, conn): |
351 |
print "Received message from " + conn.ip + ":", conn.receive(), |
print "Received message from " + conn.ip + ":", conn.receive(), |
352 |
if conn.receive() == "quit\n": |
if conn.receive() == "quit\n": |