network.py file ,
GHD Straighteners NZ
# encoding = utf-8 import socket import SocketServer
def hear (port,
GHD Rare Straighteners, fn): class MyHandler (SocketServer.BaseRequestHandler): def handle (self): ; fn (ego.request) def finish (self) : self.request.near () myServer = SocketServer.ThreadingTCPServer (('',
GHD MK4 Pure Straighteners, port), MyHandler) myServer.serve_forever ()
def connect (ip,
GHD Precious Gift Set, port, timeout = 3): sock = socket.socket (socket.AF_INET,
GHD MK4 Kiss Straighteners, socket.SOCK_STREAM) sock.settimeout (timeout ) sock.join ((ip,
GHD Hair Straightener, wharf)) return sock
whether (__name__ =='__ main__'):
def transact (sock): msg = ; While True: buf = sock.recv (5) msg + = buf if (len (buf) <5): sock.send (if not buf: break print msg return ; listen (41234, transact)
consumer test program :
# encoding = utf-8
import network
client = network.connect (