{"id":22062889,"url":"https://github.com/lwahlmeier/python-litesockets","last_synced_at":"2026-05-09T14:43:16.815Z","repository":{"id":17754933,"uuid":"20607589","full_name":"lwahlmeier/python-litesockets","owner":"lwahlmeier","description":"litesockets for python","archived":false,"fork":false,"pushed_at":"2017-05-23T13:30:23.000Z","size":74,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-28T23:48:18.521Z","etag":null,"topics":["linux","multithreading","network","networking","python","threading","windows"],"latest_commit_sha":null,"homepage":null,"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/lwahlmeier.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSES.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-08T02:35:02.000Z","updated_at":"2017-03-05T22:38:30.000Z","dependencies_parsed_at":"2022-07-26T19:32:08.614Z","dependency_job_id":null,"html_url":"https://github.com/lwahlmeier/python-litesockets","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwahlmeier%2Fpython-litesockets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwahlmeier%2Fpython-litesockets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwahlmeier%2Fpython-litesockets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwahlmeier%2Fpython-litesockets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lwahlmeier","download_url":"https://codeload.github.com/lwahlmeier/python-litesockets/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245144021,"owners_count":20568049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["linux","multithreading","network","networking","python","threading","windows"],"created_at":"2024-11-30T18:27:33.799Z","updated_at":"2026-05-09T14:43:16.770Z","avatar_url":"https://github.com/lwahlmeier.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# litesockets\nlitesockets is a simple thread safe concurrent networking library.  The main design is for either servers or load tools.  \n\nIt helps manage many connections, forcing each connection to process in order but allowing any indivdial connections to work independantly.\n\n## Basics\nThere are 3 main objects that you deal with in litesockets.\n\n* **SocketExecuter** - Processes all network connections enforcing each connection to be handled in order.  This is used by all connection types.\n* **Server** - Servers open listen ports and create Clients when a connection is esstablished.\n* **Client** - These are the actual connections that are read/written to.\n\nEvery connection type has an implementation of Client/Server (UdpClient/TcpClient/SSLServer).\n### Creating a simple Client\n\n```python\nfrom litesockets import SocketExecuter\nimport time\n\n#This starts a SocketExecuter with default of 5 threads\nSE = SocketExecuter()\n\n#This create a tcp client that points to www.google.com (its not connected yet)\nclient = SE.createTcpClient(\"www.google.com\", 80)\n\ndef onRead(client):\n    data = client.getRead()\n    print data\n    \ndef onClose(client):\n    print \"Client closed, \", client\n            \n#Now we assign a function pointer that takes 1 arg to the clients reader\nclient.setReader(onRead)\nclient.addCloseListener(onClose)\n\n#To Connect the socket call .connect(), once the connection is made when data is sent the read callback will be called\nclient.connect()\n\n#send an http request to google\nclient.addWrite(\"GET / HTTP/1.1\\r\\nConnection: close\\r\\nUser-Agent: curl/X.XX.0\\r\\nHost: www.google.com\\r\\nAccept: */*\\r\\n\\r\\n\")\ntime.sleep(5)\n\n```\n        \nAt this point you should the http/html output from www.google.com.\n        \n### Createing a simple Server\n\n```python\nfrom litesockets import SocketExecuter\nimport time\n\n#This starts a SocketExecuter with default of 5 threads\nSE = SocketExecuter()\n\n#creates a tcpServer listening on localhost port 11882 (socket is not open yet)\nserver = SE.createTcpServer(\"localhost\", 11882)\n\n#clients read callback\ndef onRead(client):\n    data = client.getRead()\n    print data\n\n#This is ran once the far side is connected\ndef onNewConnection(client):\n    print \"Got new TCPClient\", client\n    #need to add the client to the SocketExecuter to be able to do anythign with it\n    client.setReader(onRead)\n    client.addWrite(\"hello\\n\")\n    #if we wanted to check for incoming data we would add a reader to the client\n    time.sleep(.01)\n    #Close the clients connection\n    client.close()\n        \n#We assign a fuction with 1 argument that will get a client for the server\nserver.setOnClientnewConnection)\n        \n#The socket is not open, but will not yet accept anything\nserver.start()\n        \ntime.sleep(120)\n```\n        \nIf you now ran \"telnet localhost 11882\" you would get the message \"hello\" and then disconnected\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flwahlmeier%2Fpython-litesockets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flwahlmeier%2Fpython-litesockets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flwahlmeier%2Fpython-litesockets/lists"}