{"id":13802063,"url":"https://github.com/jczic/XAsyncSockets","last_synced_at":"2025-05-13T12:32:23.616Z","repository":{"id":121870883,"uuid":"160945274","full_name":"jczic/XAsyncSockets","owner":"jczic","description":"XAsyncSockets is an efficient Python/MicroPython library of managed asynchronous sockets.","archived":false,"fork":false,"pushed_at":"2024-04-02T21:44:40.000Z","size":302,"stargazers_count":35,"open_issues_count":2,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-04-22T12:33:32.153Z","etag":null,"topics":["async","async-programming","asynchronous","client","client-server","concurrent-processes","esp32","fifo-queue","hc2","micropython","pool","pycom","python","server","sockets","ssl","tcp","tls","udp","wipy"],"latest_commit_sha":null,"homepage":"https://xasyncsockets.hc2.fr","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jczic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2018-12-08T14:07:55.000Z","updated_at":"2024-08-04T00:06:53.052Z","dependencies_parsed_at":"2024-01-25T02:25:24.347Z","dependency_job_id":"206590d6-279a-4fce-a702-9c5cb39b76db","html_url":"https://github.com/jczic/XAsyncSockets","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jczic%2FXAsyncSockets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jczic%2FXAsyncSockets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jczic%2FXAsyncSockets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jczic%2FXAsyncSockets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jczic","download_url":"https://codeload.github.com/jczic/XAsyncSockets/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225217952,"owners_count":17439712,"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":["async","async-programming","asynchronous","client","client-server","concurrent-processes","esp32","fifo-queue","hc2","micropython","pool","pycom","python","server","sockets","ssl","tcp","tls","udp","wipy"],"created_at":"2024-08-04T00:01:34.724Z","updated_at":"2024-11-18T17:30:48.705Z","avatar_url":"https://github.com/jczic.png","language":"Python","readme":"## XAsyncSockets is an efficient Python/MicroPython library of managed asynchronous sockets.\n\n![HC²](hc2.png \"HC²\")\n\n#### Very easy to integrate and very light with one file only :\n- `\"XAsyncSockets.py\"`\n\n#### XAsyncSockets features :\n- Managed asynchronous sockets in a pool (up to thousands!)\n- Works directly with I/O to receive and send very quickly\n- Supports very large number of simultaneous TCP connections\n- Supports concurrent synchronous processing operations if necessary (threaded)\n- Implementation of TCP servers\n- Implementation of TCP clients\n- Implementation of UDP datagrams (sender and/or receiver)\n- TCP client can event after a specified size of data or a text line received\n- Each connections and receivings can waiting during a specified time\n- The reasons of TCP client closures are returned\n- Really robust, very fast and easy to use\n- Compatible with MicroPython implementation (sockets layer, FiFo queue, perf counter)\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"diagram.png\"\u003e\n\u003c/p\u003e\n\n### *XAsyncSockets* classes :\n\n| Class name | Description |\n| - | - |\n| XAsyncSocketsPool | Managed pool of 'XAsyncSocket' objects |\n| XClosedReason | Enumerator of 'XAsyncSocket' closing reasons |\n| XAsyncSocket | Abstract class of managed asynchronous sockets |\n| XAsyncTCPServer | TCP server implementation of 'XAsyncSocket' |\n| XAsyncTCPClient | TCP client implementation of 'XAsyncSocket' |\n| XAsyncUDPDatagram | UDP sender/recever implementation of 'XAsyncSocket' |\n| XBufferSlot | Managed buffer |\n| XBufferSlots | Managed buffers collection |\n| XFiFo | Dedicated FiFo queue |\n\n### *XAsyncSockets* exceptions :\n\n| Class name | Description |\n| - | - |\n| XAsyncSocketsPoolException | Exception class for 'XAsyncSocketsPool' |\n| XAsyncSocketException | Exception class for 'XAsyncSocket' |\n| XAsyncTCPServerException | Exception class for 'XAsyncTCPServer' |\n| XAsyncTCPClientException | Exception class for 'XAsyncTCPClient' |\n| XAsyncUDPDatagramException | Exception class for 'XAsyncUDPDatagram' |\n| XFiFoException | Exception class for 'XFiFo' |\n\n### *XAsyncSocketsPool* class details :\n\n| Method | Arguments |\n| - | - |\n| Constructor | None |\n| GetAllAsyncSockets | None |\n| GetAsyncSocketByID | `id` (int) |\n| AsyncWaitEvents | `threadsCount=0` (int) |\n| StopWaitEvents | None |\n\n| Property | Details |\n| - | - |\n| WaitEventsProcessing | Return `True` if \"WaitEvents\" is in processing |\n\n( Do not call directly the methods `AddAsyncSocket`, `RemoveAsyncSocket`, `NotifyNextReadyForReading` and `NotifyNextReadyForWriting` )\n\n### *XClosedReason* class details :\n\n| Static variable | Value |\n| - | - |\n| Error | 0x00 |\n| ClosedByHost | 0x01 |\n| ClosedByPeer | 0x02 |\n| Timeout | 0x03 |\n\n### *XAsyncSocket* class details :\n\n| Method | Arguments |\n| - | - |\n| GetAsyncSocketsPool | None |\n| GetSocketObj | None |\n| Close | None |\n\n| Property | Details |\n| - | - |\n| SocketID | Get the opened socket unique ID |\n| OnClosed | Get or set an event of type f(closedReason) |\n| State | Get or set a custom object |\n\n### *XAsyncTCPServer* class details :\n\n| Method | Arguments |\n| - | - |\n| Create (static) | `asyncSocketsPool`, `srvAddr` (tuple of ip and port), `srvBacklog=256` (int), `bufSlots=None` |\n\n| Property | Details |\n| - | - |\n| SrvAddr | Tuple of ip and port |\n| OnClientAccepted | Get or set an event of type f(xAsyncTCPServer, xAsyncTCPClient) |\n\n### *XAsyncTCPClient* class details :\n\n| Method | Arguments |\n| - | - |\n| Create (static) | `asyncSocketsPool`, `srvAddr` (tuple of ip and port), `connectTimeout=5` (int), `recvBufLen=4096` (int), `sendBufLen=4096`(int), `connectAsync=True` (bool) |\n| AsyncRecvLine | `lineEncoding='UTF-8'`, `onLineRecv=None` (function), `onLineRecvArg=None` (object)`, timeoutSec=None` (int) |\n| AsyncRecvData | `size=None` (int), `onDataRecv=None` (function), `onDataRecvArg=None` (object), `timeoutSec=None` (int) |\n| AsyncSendData | `data` (bytes or buffer protocol), `onDataSent=None` (function), `onDataSentArg=None` (object) |\n| AsyncSendSendingBuffer | `size=None` (int), `onDataSent=None` (function), `onDataSentArg=None` (object) |\n| StartSSL | `keyfile=None`, `certfile=None`, `server_side=False`, `cert_reqs=ssl.CERT_NONE`, `ca_certs=None` |\n| StartSSLContext | `sslContext`, `serverSide=False` |\n- `onLineRecv` is a callback event of type f(xAsyncTCPClient, line, arg)\n- `onDataRecv` is a callback event of type f(xAsyncTCPClient, data, arg)\n- `onDataSent` is a callback event of type f(xAsyncTCPClient, arg)\n- `StartSSL` and `StartSSLContext` doesn't works on MicroPython (in asynchronous non-blocking sockets mode)\n- It is widely recommended to use `StartSSLContext` rather than `StartSSL` (old version)\n\n| Property | Details |\n| - | - |\n| SrvAddr | Tuple of ip and port |\n| CliAddr | Tuple of ip and port |\n| IsSSL | Return `True` if SSL is used |\n| SendingBuffer | Get the existing buffer (memoryview) used to send data |\n| OnFailsToConnect | Get or set an event of type f(xAsyncTCPClient) |\n| OnConnected | Get or set an event of type f(xAsyncTCPClient) |\n\n### *XAsyncUDPDatagram* class details :\n\n| Method | Arguments |\n| - | - |\n| Create (static) | `asyncSocketsPool`, `localAddr=None` (tuple of ip and port), `recvBufLen=4096` (int), `broadcast=False` (bool) |\n| AsyncSendDatagram | `datagram` (bytes or buffer protocol), `remoteAddr` (tuple of ip and port), `onDataSent=None` (function), `onDataSentArg=None` (object) |\n- onDataSent is a callback event of type f(xAsyncUDPDatagram, arg)\n\n| Property | Details |\n| - | - |\n| LocalAddr | Tuple of ip and port |\n| OnRecv | Get or set an event of type f(xAsyncUDPDatagram, remoteAddr, datagram) |\n| OnFailsToSend | Get or set an event of type f(xAsyncUDPDatagram, datagram, remoteAddr) |\n\n### *XBufferSlot* class details :\n\n| Method | Arguments |\n| - | - |\n| Constructor | `size` (int), `keepAlloc=True` (bool) |\n\n| Property | Details |\n| - | - |\n| Available | Get or set the availability of the slot |\n| Size | Get the buffer size of the slot |\n| Buffer | Get the buffer of the slot |\n\n### *XBufferSlots* class details :\n\n| Method | Arguments |\n| - | - |\n| Constructor | `slotsCount` (int), `slotsSize` (int), `keepAlloc=True` (bool) |\n| GetAvailableSlot | None |\n\n| Property | Details |\n| - | - |\n| SlotsCount | Get the number of slots |\n| SlotsSize | Get the buffer size of each slots |\n| Slots | Get the list of slots |\n\n### *XFiFo* class details :\n\n| Method | Arguments |\n| - | - |\n| Constructor | None |\n| Put | `obj` (object) |\n| Get | None |\n| Clear | None |\n\n| Property | Details |\n| - | - |\n| Empty | Return `True` if the FiFo is empty |\n\n### By JC`zic for [HC²](https://www.hc2.fr) ;')\n\n*Keep it simple, stupid* :+1:\n","funding_links":[],"categories":["Libraries"],"sub_categories":["Communications"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjczic%2FXAsyncSockets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjczic%2FXAsyncSockets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjczic%2FXAsyncSockets/lists"}