Then after defining clientsock, write a print statement as "print clientsock", see what it will print, None or a object?
Sönmez ANIL KARADAĞ wrote: > ok , arranged block.but program give error global name 'clientsock' is not > defined " ,.. > > 2007/3/17, Sönmez Kartal <[EMAIL PROTECTED]>: >> >> Hi, >> >> You should check your script's indentation. Especially, last "while 1:" >> block's. >> >> Sönmez >> >> ANIL KARADAĞ wrote: >> > hi, i made a program in python but received global name error. the >> program >> > code; >> > serverhost = '127.0.0.1' >> > serverport = 2000 >> > BUFSIZ = 1024 >> > addr = (serverhost,serverport) >> > if str(sys.argv).find("-s") == -1: >> > cs = socket(AF_INET, SOCK_STREAM,0) # create a TCP >> socket >> > cs.connect(addr) >> > key=1 >> > main() >> > else: >> > serversock = socket(AF_INET, SOCK_STREAM) # create a TCP >> socket >> > serversock.bind(addr) >> > serversock.listen(2) >> > key=2 >> > print 'waiting for connection…' >> > while 1: >> > clientsock, addr = serversock.accept() >> > print '…connected from:', addr,clientsock >> > main() >> > serversock.close() >> > >> > what is difference cs and clientsock? i use cs in main() function or >> > others, >> > but don't use clientsock not call from main() " data = >> > clientsock.recv(BUFSIZ) >> > NameError: global name 'clientsock' is not defined " >> > >> > i am sorry, i little know english >> > >> >> -- http://mail.python.org/mailman/listinfo/python-list