Demo entry 6519719

py

   

Submitted by anonymous on May 31, 2017 at 12:36
Language: Python. Code size: 408 Bytes.

sockfd = socket(AF_INET,SOCK_STREAM)
sockfd.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
sockfd.bind(ADDR)
sockfd.listen(5)
while True:
    print 'waiting for connection...'
    cliSockfd,addr = sockfd.accept()
    print '...connected from:',addr

    while True:
        msg = cliSockfd.recv(4096)
        if msg == 'close':
            print 'client closed'
            break
        handle(msg)

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).