SoFunction
Updated on 2024-11-15

Example of python network programming (client-side and server-side)


if __name__ == '__main__':  
    import socket  
    sock = (socket.AF_INET, socket.SOCK_STREAM)  
    (('localhost', 8001))  
    (5)  
    while True:  
        connection,address = ()  
        try:  
            (5)  
            buf = (1024)  
            if buf == '1':  
                ('welcome to server!')  
            else:  
                ('please go out!')  
        except :  
            print 'time out'  
        ()