Return to Snippet

Revision: 6194
at May 6, 2008 12:11 by cirio


Initial Code
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()

Initial URL

                                

Initial Description
http://lineguides.netsons.org

Initial Title
Server example [function: chat]

Initial Tags
server

Initial Language
Python