{"id":15290506,"url":"https://github.com/shahaf-f-s/socketsio","last_synced_at":"2026-01-19T06:01:29.716Z","repository":{"id":218220757,"uuid":"689237599","full_name":"Shahaf-F-S/socketsio","owner":"Shahaf-F-S","description":"A python wrapper around socket for generalized communication protocols, unified socket interface, utility methods, and modular protocol swapping capeabilities. Including a socket based Pub/Sub system.","archived":false,"fork":false,"pushed_at":"2024-04-19T12:44:31.000Z","size":89,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-21T06:44:14.176Z","etag":null,"topics":["pubsub","socket","socket-io","socket-programming"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Shahaf-F-S.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-09T07:20:09.000Z","updated_at":"2025-03-12T17:12:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"a347a681-c841-4e5b-bd64-92e17d3ce847","html_url":"https://github.com/Shahaf-F-S/socketsio","commit_stats":null,"previous_names":["shahaf-f-s/socketsio"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Shahaf-F-S/socketsio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shahaf-F-S%2Fsocketsio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shahaf-F-S%2Fsocketsio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shahaf-F-S%2Fsocketsio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shahaf-F-S%2Fsocketsio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shahaf-F-S","download_url":"https://codeload.github.com/Shahaf-F-S/socketsio/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shahaf-F-S%2Fsocketsio/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28562232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T03:31:16.861Z","status":"ssl_error","status_checked_at":"2026-01-19T03:31:15.069Z","response_time":67,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pubsub","socket","socket-io","socket-programming"],"created_at":"2024-09-30T16:08:26.222Z","updated_at":"2026-01-19T06:01:29.703Z","avatar_url":"https://github.com/Shahaf-F-S.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sockets-io\n\n\u003e A python wrapper around the builtin socket module, for generalized communication protocols, unified socket interface, utility methods, and modular protocol swapping capeabilities. Including a socket based Pub/Sub system.\n\n## Installation\n\n```\npip install sockets-io\n```\n\n## examples\n\nbasic server socket threading based\n\n```python\nfrom socketsio import Server, Socket, BHP, TCP, UDP\n\nfrom looperation import Handler, Operator\n\ndef action(server: Server, client: Socket) -\u003e None:\n    \n    with Handler(\n          exception_handler=print,\n          cleanup_callback=lambda h: client.close()\n    ):\n        while not (client.closed or server.closed):\n            received, address = client.receive()\n            \n            if not received:\n                continue\n            \n            print(\"server:\", (received, address))\n            \n            sent = (\n              f\"server received from \"\n              f\"{address}: \".encode() + received\n            )\n            \n            client.send(sent)\n\nHOST = \"127.0.0.1\"\nPROTOCOL = 'TCP'\nPORT = 5000\n\nif PROTOCOL == 'UDP':\n    protocol = UDP()\n\nelif PROTOCOL == 'TCP':\n    protocol = BHP(TCP())\n\nelse:\n    raise ValueError(f\"Invalid protocol type: {PROTOCOL}\")\n\nserver = Server(protocol)\nserver.bind((HOST, PORT))\n\nservice = Operator(\n  operation=lambda: server.handle(action=action)\n)\nservice.run()\n```\n\nbasic client socket\n\n```python\nfrom socketsio import Client, BHP, TCP, UDP\n\nHOST = \"127.0.0.1\"\nPROTOCOL = 'TCP'\nPORT = 5000\n\nif PROTOCOL == 'UDP':\n    protocol = UDP()\n\nelif PROTOCOL == 'TCP':\n    protocol = BHP(TCP())\n\nelse:\n    raise ValueError(f\"Invalid protocol type: {PROTOCOL}\")\n\nclient = Client(protocol)\nclient.connect((HOST, PORT))\n\nfor _ in range(2):\n    client.send((\", \".join([\"hello world\"] * 3)).encode())\n    print(\"client:\", client.receive())\n\n```\n\npubsub server with authentication\n\n```python\nimport time\nimport random\n\nfrom looperation import Operator\nfrom socketsio import Server\n\nfrom socketsio.pubsub import DataStore, Data, SubscriptionStreamer, Authorization\n\nIP = \"127.0.0.1\"\nPORT = 5080\n\nDELAY = 0.00001\n\nAUTHORIZED = [\n    {'name': 'abc', 'password': '123'}\n]\n\nclass Producer:\n\n    ACTION = \"action\"\n    BUY = \"buy\"\n    SELL = \"sell\"\n\n    NAMES = ['AAPL', \"AMZN\", \"GOOG\", \"TSLA\", \"META\"]\n    BUY_DATA = {ACTION: BUY}\n    SELL_DATA = {ACTION: SELL}\n\n    def next(self) -\u003e Data:\n\n        return Data(\n            name=random.choice(self.NAMES),\n            data=random.choice((self.BUY_DATA, self.SELL_DATA)),\n            time=time.time()\n        )\n\nstorage = DataStore()\n\nproducer = Producer()\n\nscreener = Operator(\n    operation=lambda: storage.insert(producer.next()),\n    delay=DELAY\n)\n\nstreamer = SubscriptionStreamer(\n    storage=storage,\n    authenticate=lambda controller, data: Authorization(data.data in AUTHORIZED),\n    on_unauthenticated=lambda controller, data: (time.sleep(0.5), controller.close()),\n    on_join=lambda controller: print(f\"client connected: {controller.socket.address}\"),\n    on_disconnect=lambda controller: print(f\"client disconnected: {controller.socket.address}\"),\n)\n\nserver = Server()\nserver.bind((IP, PORT))\n\nservice = Operator(\n    operation=lambda: server.handle(\n        action=lambda _, socket: streamer.controller(\n            socket=socket, exception_handler=print\n        ).run(send=True, receive=True, block=True)\n    ),\n    termination=lambda: (\n        print(\"disconnecting server\"),\n        server.close(),\n        print(\"server disconnected\")\n    )\n)\n\nscreener.run(block=False)\nservice.run(block=True)\n```\n\npubsub client with authentication\n\n```python\nfrom looperation import Handler\nfrom socketsio import Client\n\nfrom socketsio.pubsub import ClientSubscriber, DataStore, Data\n\nIP = \"127.0.0.1\"\nPORT = 5080\n\nstorage = DataStore()\n\nclient = Client()\nclient.connect((IP, PORT))\n\nsubscriber = ClientSubscriber(socket=client, storage=storage)\nsubscriber.queue_socket.run(block=False)\n\nsubscriber.authenticate({'name': 'abc', 'password': '123'})\n\nprint(Data.load(Data.decode(client.receive()[0])))\n\nsubscriber.subscribe(['AAPL', \"AMZN\", \"GOOG\"])\n\nwith Handler(\n    exception_callback=lambda h: client.close(),\n    exception_handler=print\n):\n    while True:\n        print(subscriber.data())\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshahaf-f-s%2Fsocketsio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshahaf-f-s%2Fsocketsio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshahaf-f-s%2Fsocketsio/lists"}