ondrejsika.com

python-simplesocket documentation

Simple socket server in Python

Authors

Ondrej Sika ondrejsika.com dev@ondrejsika.com

Source

Documentation ondrejsika.com/docs/python-simplesocket
Python Package Index pypi.python.org/pypi/simplesocket
GitHub github.com/sikaondrej/python-simplesocket

Instalation

Instalation is very simple via pip.
# pip install simplesocket

Server

from simplesocket import Server

def handler(req):
    return 2*req

server = Server(("localhost", 9999), handler)

server.serve_forever()

Client

from simplesocket import client_request

request = "hello"
response = client_request(("localhost", 9999), request)