Skip to main content

Multithreaded TCP server/client

Project description


simplified tcp networking library

note: This is not a websocket.

sockdot allows you to create server/client applications without having to use web-standard protocols in your application. the library is a threaded tcp socket and allows for events to be used, making it easy to inpliment in server/client application. i created this library to meet my needs in a Lan software project, so 't could be of use to someone else :).


pip install sockdot

Installing from source.

git clone
cd sockdot
python sdist bdist_wheel
pip install dist\sockdot-1.0.1-py3-none-any.whl


from sockdot import Server
from import Event

serverevents = Event()
server = Server(debug=True)

def on_data_recieved(client, data):
	print("recieved:", data)
	server.send(client, f"you said {data}")

def on_connection_open(client):
	print(f"client {client} joined")

def on_connection_close(client):
	print(client, "closed connection")

def on_server_destruct():
	print("server shutdown")

def on_error(exception, message):
	# print(f"error {exception} occured, message:", message)

def on_port_changed(port):
	print("server changed port to", port)

def on_running_changed(running):
	print("server is running" if running else "server is not running")


the server's runs on the machine's host name

from sockdot import host
# outputs ["host_name", "host_ip"]

import time, threading
from sockdot import Client
from import Event

clientevents = Event()
client = Client(host="rubbie-io", debug=True)

def start(connected):
	if connected:
		for i in range(10):

def on_data_recieved(data):
	print(f"got {data} from server")

def on_connected_changed(connected):
	threading.Thread(target=start, args=(connected,)).start()

def on_error(exception, message):
	print(f"error {exception} occured, message:", message)

def on_host_changed(host):

def on_port_changed(port):

def on_handshake_started():

def on_handshake_ended(result):


Adding authenthecation

create a file ".auth", could be anything you want, but in my case, i named it ".auth". the file contains keys and values of security parameters in json format.

	"SECURITY_KEY" : "secret key",

in, make this change:
note that it is also possible for auth settings to be in a python dictionary, use could use any one you want. the auth keyword argument can be a str (filename) type or dict (auth dictionary).

# from file...
server = Server(debug=True, auth=".auth")

# from dictionary
server = Server(debug=True, auth={
	"SECURITY_KEY" : "secret key",

in, make this change:

client.connect(authkey="secret key")

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sockdot-1.0.1.tar.gz (5.2 kB view hashes)

Uploaded Source

Built Distribution

sockdot-1.0.1-py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page