{"id":26536891,"url":"https://github.com/jmatth11/websocket-c","last_synced_at":"2025-10-16T17:15:23.438Z","repository":{"id":283713680,"uuid":"952188348","full_name":"jmatth11/websocket-c","owner":"jmatth11","description":"connections with websockets in C lang","archived":false,"fork":false,"pushed_at":"2025-03-21T18:31:07.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-21T18:34:53.805Z","etag":null,"topics":["c","client","websockets"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmatth11.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2025-03-20T21:54:41.000Z","updated_at":"2025-03-21T18:31:11.000Z","dependencies_parsed_at":"2025-03-21T18:48:40.197Z","dependency_job_id":null,"html_url":"https://github.com/jmatth11/websocket-c","commit_stats":null,"previous_names":["jmatth11/websocket-c"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmatth11%2Fwebsocket-c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmatth11%2Fwebsocket-c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmatth11%2Fwebsocket-c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmatth11%2Fwebsocket-c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmatth11","download_url":"https://codeload.github.com/jmatth11/websocket-c/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244875043,"owners_count":20524591,"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","client","websockets"],"created_at":"2025-03-21T22:17:32.906Z","updated_at":"2025-10-16T17:15:23.397Z","avatar_url":"https://github.com/jmatth11.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WebSocket-C\n\nSimple WebSocket library in C.\n\nCurrently only implements the client side to talk to a server.\n\n## Example\n\n### Manual Loop\n\nExample of using your own listener loop.\n\n```c\n#include \u003cstddef.h\u003e\n#include \u003cstdio.h\u003e\n#include \u003cstring.h\u003e\n\n#include \"websocket.h\"\n\n#define LISTENER_URL \"ws://127.0.0.1:3000/ws\"\n\nint main(int argc, char **argv) {\n  struct ws_client_t client;\n  if (!ws_client_from_str(LISTENER_URL, strlen(LISTENER_URL), \u0026client)) {\n    fprintf(stderr, \"client from string URL failed.\\n\");\n    return 1;\n  }\n  if (!ws_client_connect(\u0026client)) {\n    fprintf(stderr, \"client failed to connect.\\n\");\n    return 1;\n  }\n  while (1) {\n    printf(\"waiting for messages...\\n\");\n    struct ws_message_t *msg = NULL;\n    if (!ws_client_next_msg(\u0026client, \u0026msg)) {\n      fprintf(stderr, \"client failed to recv.\\n\");\n      break;\n    }\n    if (msg == NULL) {\n      fprintf(stderr, \"message was null\\n\");\n      break;\n    }\n\n    // handle message here\n\n    ws_message_free(msg);\n    free(msg);\n  }\n  ws_client_free(\u0026client);\n  return 0;\n}\n```\n\n### Callback Loop\n\nExample of using the supplied `ws_client_on_msg` callback loop.\n\n```c\n#include \u003cstdbool.h\u003e\n#include \u003cstddef.h\u003e\n#include \u003cstdio.h\u003e\n#include \u003cstring.h\u003e\n\n#include \"headers/reader.h\"\n#include \"headers/websocket.h\"\n\n#define LISTENER_URL \"ws://127.0.0.1:3000/ws\"\n\nstatic bool callback(struct ws_client_t *client, struct ws_message_t *msg, void *context) {\n  // handle the message\n  return true;\n}\n\nint main(int argc, char **argv) {\n  struct ws_client_t client;\n  if (!ws_client_from_str(LISTENER_URL, strlen(LISTENER_URL), \u0026client)) {\n    fprintf(stderr, \"client from string URL failed.\\n\");\n    return 1;\n  }\n  if (!ws_client_connect(\u0026client)) {\n    fprintf(stderr, \"client failed to connect.\\n\");\n    return 1;\n  }\n  printf(\"listening for messages...\\n\");\n  ws_client_on_msg(\u0026client, callback, NULL);\n  ws_client_free(\u0026client);\n  return 0;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmatth11%2Fwebsocket-c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmatth11%2Fwebsocket-c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmatth11%2Fwebsocket-c/lists"}