{"id":21660672,"url":"https://github.com/d-a-v/libnowebsocket","last_synced_at":"2025-03-20T05:26:44.207Z","repository":{"id":71090757,"uuid":"143270250","full_name":"d-a-v/libNoWebsocket","owner":"d-a-v","description":"native stream sockets between C and HTML5","archived":false,"fork":false,"pushed_at":"2019-06-04T23:15:56.000Z","size":301,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-25T07:10:30.570Z","etag":null,"topics":["c","library","posix-compatible","websocket"],"latest_commit_sha":null,"homepage":"","language":"C","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/d-a-v.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":"2018-08-02T09:07:44.000Z","updated_at":"2022-03-03T10:44:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"617d8e34-40d9-4cab-af90-034845344669","html_url":"https://github.com/d-a-v/libNoWebsocket","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-a-v%2FlibNoWebsocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-a-v%2FlibNoWebsocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-a-v%2FlibNoWebsocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-a-v%2FlibNoWebsocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d-a-v","download_url":"https://codeload.github.com/d-a-v/libNoWebsocket/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244556535,"owners_count":20471643,"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":["c","library","posix-compatible","websocket"],"created_at":"2024-11-25T09:37:10.160Z","updated_at":"2025-03-20T05:26:44.186Z","avatar_url":"https://github.com/d-a-v.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"Name\n\nnowsread, nowswrite, nowsclose — read, write, close a regular stream\nsocket when peer is a websocket.\n\nPROLOG\n\nThis manual page will never be part of the POSIX Programmer’s Manual.\n\nnowsread, nowswrite and nowsclose are designed to be similar to posix\nread, write and close. Their purpose is to provide native sockets to\nHTML5 web browsers. This is not yet allowed by standards, but the\nother way around is not forbidden. These functions mimic posix’s\nread, write and close and transparently emulate the websocket\nprotocol.\n\nThese functions allow their users to communicate with HTML5-enabled\nweb browsers using legacy knowledge and habits gained through years\nof experience on network programming with TCP stream sockets and\nPOSIX API as a reference.\n\nSYNOPSYS\n\n#include \u003cnows.h\u003e\n\nssize_t nowsread (int sock, void* data, size_t len);\n\nssize_t nowswrite (int sock, const void* data, size_t len);\n\nint nowsclose (int sock);\n\nint nows_simulate_client (int sock);\n\nDESCRIPTION\n\nnowsread(3) is very similar to read(3POSIX) in its arguments,\nbehavior, return value, in blocking or non blocking mode, when sock\nis a STREAMS socket in byte-stream mode (message-nondiscard and \nmessage-discard modes are yet unconsidered). Same goes to nowswrite\n(3) regarding write(3POSIX). The websocket protocol includes a\nhandshake process which sadly breaks symmetry between peers. As\ngenerally HTML5 browsers act as websocket clients, nowsread(3) and\nnowswrite(3) act by default as websocket server (even if the socket \nsock is a SOCK_STREAM client). A call to nows_simulate_client(3)\nprior to nowsread(3) and nowswrite(3) will switch this behavior.\n\nNothing beeing perfect, here is a list of specific differences or\nrelevant notices:\n\n- blocking mode\n    read(3POSIX) blocks the caller until exactly len bytes are\n    received. Similarly nowsread(3) blocks the caller until at least\n    one byte is received, but due to the nature of the websocket\n    protocol, this does not guarantee that exactly len bytes are\n    received. The returned value indicates the amount of received\n    bytes in the data buffer. nowswrite(3) has however the same\n    behavior as write(3POSIX).\n- non-blocking mode\n    Any value (greater than 0) given to len will follow read/write\n    (3POSIX) behavior.\n- websocket specifics or restrictions\n    Underlying ping-pong facility is not implemented yet. Only text\n    buffers are sent or received. This is subject for improvements.\n\nnowsclose(3) is similar to close(3POSIX).\n\nnows_simulate_client(3) sets this side of the stream to act as a\nwebsocket client.\n\nRETURN VALUE\n\nPlease refer to read(3POSIX), write(3POSIX). To summarize, 0 always\nindicates EOF, -1 an error and in that case errno is set. errno can\nbe set to EAGAIN even when in blocking mode. However in blocking mode\nEAGAIN is never continuously returned and cannot induce an active\nloop. Otherwise the returned value indicates the number of bytes sent\nor received.\n\nnow_simulate_client(3) returns 0 on success, -1 on error and in that\ncase errno is set.\n\nERRORS\n\nThey are the same as with read(3POSIX), write(3POSIX) and close\n(3POSIX). Additionnaly,\n\nENOMEM\n    can be returned in case of memory shortage.\nEAGAIN\n    can be returned by nowsread(3) or nowswrite(3) in blocking mode\n    (however never continuously thus not inducing an active loop).\n    This is subject for improvements.\n\nLICENSE\n\nGPLv2 (due to sha1 embedded library - subject for changes)\n\nAUTHOR\n\nCNRS\n\nhttps://redmine.laas.fr/projects/libnowebsocket\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd-a-v%2Flibnowebsocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd-a-v%2Flibnowebsocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd-a-v%2Flibnowebsocket/lists"}