Simple TCP socket server with select
Installation
Install it with pip:
$ pip install simple-socket-server
Or you can add it as dependency in requirements.txt file of your python application:
simple-socket-server~=1.8
Usage
Easy way to understand how it works is testing socket server via telnet terminal:
from socket import socket
from simple_socket_server import SimpleSocketServer
socket_server = SimpleSocketServer()
@socket_server.on('connect')
def on_connect(sock: socket, peer):
print('New connection from %s:%s' % peer)
socket_server.send(sock, bytes('What is your name?\r\n', 'utf-8'))
@socket_server.on('disconnect')
def on_disconnect(_sock, peer):
print('Connection from %s:%s is closed' % peer)
@socket_server.on('message')
def on_message(sock: socket, peer, message: bytes):
print('Incoming data from %s:%s' % peer, message)
socket_server.send(sock, bytes('Hi, ', 'utf-8') + message)
socket_server.run(host='0.0.0.0', port=5000)
Then you can connect to server:
telnet 127.0.0.1 5000
Metadata
Release files for simple-socket-server 1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| simple-socket-server-1.8.tar.gz | 4.4 kB | Without provenance | Details for simple-socket-server-1.8.tar.gz |
Release files / simple-socket-server-1.8.tar.gz
| Download URL | simple-socket-server-1.8.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fee786fadd2da520a3bbd0021d03b7b7bfc25ba535bfcc88da2318b1e12880b4
|
|
BLAKE2b-256 checksum How to use checksums |
3627d465c157fe7d466a75e287de4d01ef01f842cc7a7be1cb89696ea5c5a84f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Security for simple-socket-server 1.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.