/ Published in: Python
http://lineguides.netsons.org
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import socket HOST = '127.0.0.1'# Nome simbolico che rappresenta il nodo locale PORT = 90007 # Porta non privilegiata arbitraria s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((HOST, PORT)) s.listen(6) while 1: conn, addr = s.accept() data = conn.recv(1024) if data=='/quit': print '...FINE CONNESSIONE CON',addr,'...' conn.close() if not data: break print 'Client',addr,'::. \t'+data risp=raw_input('Server::. \t') conn.send(risp) conn.close()