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
------------------------------------------------------
Mailman-Users mailing list
[email protected]
http://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://www.python.org/cgi-bin/faqw-mm.py
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-users/archive%40jab.org

Security Policy: 
http://www.python.org/cgi-bin/faqw-mm.py?req=show&file=faq01.027.htp

Reply via email to