from socket import *
host = "localhost"
port = 8989
buf = 1024
addr = (host, port)
python_socket = socket(AF_INET, SOCK_STREAM)
python_socket.bind((host, port))
python_socket.listen(3) # pozwól na trzy polaczenia
while 1:
  connection, address = python_socket.accept()
  print 'polaczenie z adresem ', address
  while 1:
    data = connection.recv(1024)
    if not data: break
      print data
    if data == 'czesc\0':
      connection.send('<?xml version="1.0" encoding="|ISO-8859-2|"?><response>czesc!</response>\0')
    if data == 'do zobaczenia\0':
      connection.send('<?xml version="1.0" encoding="|ISO-8859-2|"?><response>do zobaczenia!</response>\0')
      connection.close()
