SocketServer

Bonus: simple python socket client

Comments are moderated. It may take a few minutes before your comment appears.
Markdown is supported in your comments.

import socket
def client(string):
    HOST, PORT = 'localhost', 2000
    # SOCK_STREAM == a TCP socket
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    #sock.setblocking(0)  # optional non-blocking
    sock.connect((HOST, PORT))
    sock.send(string)
    reply = sock.recv(16384)  # limit reply to 16K
    sock.close()
    return reply

assert client('2+2') == '4'
Name:
Mail: (not shown)

Please type this: