Error on Socket Server ?

GT guy.theisen at isp.lu
Fri Nov 23 10:30:11 CET 2001


Hi,

May be someone who can tell me what is wrong with this code. 

------------------------------------------------------------

import time, string, os, sys

from socket import *

def burp(worksock):
	while 1:
		data = worksock.recv(1024)
		if not data:
			break
		worksock.send("It works")
		print 'SocketServer closed ...'
	worksock.close()

HOST = ''
PORT = 8576

if __name__ == '__main__':
  
    consock = socket(AF_INET, SOCK_STREAM)
    consock.bind((HOST, PORT))
    consock.listen(5)
    print 'Socket listening for connections...'

    while 1:
	worksock, addr = connect_socket.accept()
        print  'Connected by ',addr
	 
        child_pid = os.fork()         
         
        if not child_pid: 
		connsock.close()
		
		burp(worksock)
		
		sys.exit()
	else:
		worksock.close()
-----------------------------------------------------------------

Thanks for any help

GT



More information about the Python-list mailing list