Skip to main content

Nkosi

Python Version License: MIT

Nkosi is a Python package for network device discovery and communication. It provides tools to:

  • Discover devices on your local network using ARP
  • Establish TCP/UDP communication channels
  • Create network servers and clients with minimal code
  • Send and receive messages between devices

Features

  • Device Discovery: Find all devices on your local network using ARP scanning
  • TCP Communication: Full-featured TCP server and client implementations
  • UDP Communication: UDP server and client with broadcast support
  • Easy to Use: Simple API for common networking tasks
  • Cross-platform: Works on Windows, macOS, and Linux

Installation

pip install nkosi

Quick Start

Discovering Devices on Your Network

from nkosi import discover_devices

devices = discover_devices()
for device in devices:
    print(f"IP: {device['ip']}, MAC: {device['mac']}, Hostname: {device['hostname']}")

Creating a TCP Server

from nkosi import TCPServer

def on_message_received(message, client_address):
    print(f"Received from {client_address}: {message}")

server = TCPServer(host='0.0.0.0', port=5000)
server.start(callback=on_message_received)

# Keep the server running
input("Press Enter to stop the server...")
server.stop()

Creating a TCP Client

from nkosi import TCPClient

def on_message_received(message):
    print(f"Received from server: {message}")

client = TCPClient(host='localhost', port=5000)
if client.connect(callback=on_message_received):
    client.send({"type": "greeting", "message": "Hello, server!"})
    
    # Keep the client running
    input("Press Enter to disconnect...")
    client.disconnect()

Creating a UDP Server

from nkosi import UDPServer

def on_message_received(message, client_address):
    print(f"Received from {client_address}: {message}")

server = UDPServer(host='0.0.0.0', port=5001)
server.start(callback=on_message_received)

# Keep the server running
input("Press Enter to stop the server...")
server.stop()

Creating a UDP Client

from nkosi import UDPClient

def on_message_received(message, sender_address):
    print(f"Received from {sender_address}: {message}")

client = UDPClient(host='localhost', port=5001)
if client.start(callback=on_message_received):
    client.send({"type": "greeting", "message": "Hello, server!"})
    
    # Keep the client running
    input("Press Enter to stop the client...")
    client.stop()

Command Line Interface

Nkosi also provides a simple command-line interface for common tasks.

Discover Devices

nkosi-discover

Send a Message

# Send a message to a TCP server
nkosi-send --host localhost --port 5000 --message "Hello, server!" --protocol tcp

# Send a message to a UDP server
nkosi-send --host localhost --port 5001 --message "Hello, server!" --protocol udp

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Release files for nkosi 3.4

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

Source distribution (sdist)

Source distribution for nkosi 3.4
File Size Uploaded
nkosi-3.4.tar.gz 25.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nkosi 3.4
File Interpreter ABI Platform
nkosi-3.4-py3-none-any.whl Python 3 none any Details

Total release size: 51.4 kB

Release files / nkosi-3.4.tar.gz

Download URL nkosi-3.4.tar.gz
Size 25.8 kB
Tags Source
SHA-256 checksum
How to use checksums
225f7c0b06a44c6a11b2b36913cdbdba503a35b6b42b05aa535fb8b11752f7a9
BLAKE2b-256 checksum
How to use checksums
c51b087fffa46b4c97ff50a544b2c7bf48cce421710e61a68ee3957018ee79e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.0

Release files / nkosi-3.4-py3-none-any.whl

Download URL nkosi-3.4-py3-none-any.whl
Size 25.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f8ec06384f83422685af3fa888fe31d3f3f9acf6b5a710fd1565875cff43cdf4
BLAKE2b-256 checksum
How to use checksums
ff07001225ca55e3561da53cdb54c378db1c115f48abeeeb4fef14b7f0a4770c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.0

Release history Release notifications | RSS feed

This release

3.4 This release

2 release files

3.3

2 release files

3.2

2 release files

3.0.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.0

2 release files

0.1.0

2 release files

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