Skip to main content

nil-service

Python bindings for nil-service - a high-performance networking service toolkit for building client/server applications.

Features

  • Multiple Protocols: UDP, TCP, WebSocket, HTTP, and pipe support
  • Client & Server Modes: Flexible role-based service creation
  • Event-Driven API: Async-friendly event handlers
  • Lightweight: Minimal dependencies, built on C++ for performance
  • Cross-Platform: Support for POSIX systems

Installation

pip install nil-service

Quick Start

Basic Server

from nil_service import Service

# Create an HTTP server
server = Service.http_server(port=8000)

@server.on_ready
def on_ready():
    print("Server started")

@server.on_message
def on_message(connection_id, data):
    # data is bytes
    text = data.decode("utf-8", errors="replace")
    print(f"Received from {connection_id}: {text}")
    server.send(connection_id, b"Hello back!")

server.run()

WebSocket Server

from nil_service import Service

server = Service.http_server(port=8000)
ws = server.use_ws("/ws")

@ws.on_connect
def on_connect(connection_id):
    print(f"Client {connection_id} connected")

@ws.on_message
def on_message(connection_id, data):
    text = data.decode("utf-8", errors="replace")
    print(f"Received: {text}")
    ws.publish(data)  # Broadcast to all (data is bytes)

server.run()

TCP Client

from nil_service import Service

client = Service.tcp_client(host="localhost", port=9000)

@client.on_connect
def on_connect(connection_id):
    client.send(connection_id, b"Hello Server!")

@client.on_message
def on_message(connection_id, data):
    text = data.decode("utf-8", errors="replace")
    print(f"Received: {text}")

client.run()

Service Types

Protocol Mode Use Case
self standalone Loopback/echo service
udp client/server Connectionless messaging
tcp client/server Reliable stream transport
ws client/server WebSocket communication
http server Web server with routing
pipe standalone POSIX named pipes

API Reference

Service Methods

  • run() - Block and run the event loop
  • poll() - Process pending events (non-blocking)
  • stop() - Stop the service
  • send(connection_id, data) - Send to a specific connection
  • publish(data) - Broadcast to all connections

Event Handlers

  • @service.on_ready - Service initialized
  • @service.on_connect - New connection
  • @service.on_disconnect - Connection closed
  • @service.on_message - Data received (bytes)

Documentation

For detailed API documentation and more examples, visit:

License

CC BY-NC-ND 4.0

Support

For issues, questions, or contributions, visit the GitHub repository.

Metadata

Release files for nil-service 1.0.20

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for nil-service 1.0.20
File Interpreter ABI Platform Actions
nil_service-1.0.20-py3-none-manylinux_2_39_x86_64.whl Python 3 none Linux glibc 2.39+ x86-64 Details for nil_service-1.0.20-py3-none-manylinux_2_39_x86_64.whl
nil_service-1.0.20-py3-none-any.whl Python 3 none any Details for nil_service-1.0.20-py3-none-any.whl

Total release size: 1.5 MB

Release files / nil_service-1.0.20-py3-none-manylinux_2_39_x86_64.whl

Download URL nil_service-1.0.20-py3-none-manylinux_2_39_x86_64.whl
Size 750.8 kB
Tags Linux glibc 2.39+ x86-64 Python 3
SHA-256 checksum
How to use checksums
e471819969355147615b1d6571caae07b97f9e9b3fa0268d0cb209b9fe2eea45
BLAKE2b-256 checksum
How to use checksums
6d0dc616c55eed830f1e710873ace3ae223f0fc5b7540420a5f36f3d92534637
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / nil_service-1.0.20-py3-none-any.whl

Download URL nil_service-1.0.20-py3-none-any.whl
Size 750.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b53866e1b6cdbb9d1dc743d6afe193e15b279b09ed30d8c42eea236d87b6817b
BLAKE2b-256 checksum
How to use checksums
83f9016e5bccb37e26817ca7a72fc20c0706dca6703eb689566f87adebaa417d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for nil-service 1.0.20

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page