{"id":21296927,"url":"https://github.com/reddec/mutalk","last_synced_at":"2025-07-11T18:32:08.242Z","repository":{"id":21668477,"uuid":"24989457","full_name":"reddec/mutalk","owner":"reddec","description":"UDP Multicast messaging library","archived":false,"fork":false,"pushed_at":"2020-10-26T09:41:32.000Z","size":18,"stargazers_count":40,"open_issues_count":0,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-07-02T11:02:02.049Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","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/reddec.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://reddec.net/about/#donate"]}},"created_at":"2014-10-09T13:06:20.000Z","updated_at":"2025-02-04T18:48:13.000Z","dependencies_parsed_at":"2022-08-17T21:10:32.073Z","dependency_job_id":null,"html_url":"https://github.com/reddec/mutalk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/reddec/mutalk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reddec%2Fmutalk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reddec%2Fmutalk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reddec%2Fmutalk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reddec%2Fmutalk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reddec","download_url":"https://codeload.github.com/reddec/mutalk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reddec%2Fmutalk/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264870447,"owners_count":23676232,"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":[],"created_at":"2024-11-21T14:31:03.183Z","updated_at":"2025-07-11T18:32:07.914Z","avatar_url":"https://github.com/reddec.png","language":"C","funding_links":["https://reddec.net/about/#donate"],"categories":[],"sub_categories":[],"readme":"mutalk\n======\n\n![mutalk](https://user-images.githubusercontent.com/6597086/97156868-47bb3200-17b2-11eb-8b4e-137f658459da.png)\n\n\nUDP Multicast messaging library\n\nAPI\n======\n\nSee full example in `example.c`\n\n# Includes\n\n* `#include \u003cstdbool.h\u003e`\n* `#include \u003cstdint.h\u003e`\n\n# Constants\n\n* `MUTALK_MAX_NAME_SIZE 1024`\n\n# Structures\n\n### Group definition\n\n```c\ntypedef struct mutalk_group_t {\n    struct mutalk_group_t *next, *prev; // References to nearby groups\n    char *name;                         // Group name.\n    size_t name_size;                   // Group name size in bytes\n    int fd;                             // Socket descriptor\n} mutalk_group_t;\n\n```\n\n### Message definition\n\n```c\ntypedef struct mutalk_msg_t {\n    bool error;               // Error(also timeout) flag\n    ssize_t count;            // Bytes written to buffer\n    mutalk_group_t *stream;   // Reference to group definition\n    struct in_addr source_ip; // Sender IP\n    uint16_t source_port;     // Sender port\n} mutalk_msg_t;\n```\n\n### MUTalk definition\n\n```c\ntypedef struct mutalk_t {\n    size_t cache_size;                     // Size of allocated buffer for incoming messages\n    int epoll_fd;                          // EPOLL descriptor\n    int sender_fd;                         // Socket descriptor, used for outgoing messages\n    struct mutalk_group_t *groups;         // Reference to first group definition. May be NULL\n    char *cache_data;                      // Buffer for incoming messages\n    char cache_name[MUTALK_MAX_NAME_SIZE]; // Buffer for name in incoming messages\n} mutalk_t;\n```\n\n# Types\n\n* **`mutref`** - `struct mutalk_t*`\n\n# Functions\n\n## mutalk_create\n\n```c\nmutref mutalk_create(size_t buffer_size)\n```\nCreate new instance of MUTalk engine.\nReturns NULL if something wrong (see errno message) or instance of MUTalk.\nUse `mutalk_destory` for cleaning memory.\n\n* `size_t buffer_size` Maximum size of incoming messages\n\n**This function is thread-safe**.\n\nExample:\n\n```c\n#include \"mutalk.h\"\n\nint main() {\n  mutref talk = mutalk_create(65535);\n  //... Do something\n  mutalk_destroy(talk);\n  return 0;\n}\n\n```\n\n## mutalk_destroy\n\n```c\nvoid mutalk_destroy(mutref talk)\n```\nClose all sockets and EPoll. Free all allocated memory\n\n* `mutref talk` MUTalk instance ref\n\n**This function is NOT thread-safe for one MUTalk instance**.\n\nExample: see [mutalk_create](#mutalk_create)\n\n\n## mutalk_group_add\n\n```c\nbool mutalk_group_add(mutref talk, const char* name)\n```\nJoin to MUTalk group. Do nothing if group already joined.\nReturns `true` if joined to group, otherwise false (also if already joined to group)\n\n* `mutref talk` MUTalk instance ref\n*  `const char* name` Group name. Maximum lenght defined in MUTALK_MAX_NAME_SIZE. Name can't has spaces\n\n**This function is NOT thread-safe for one MUTalk instance**\n\nExample:\n\n```c\n// See initialization in mutalk_create example\nconst char *groupName = \"some.test.group\\0\";\nif(mutalk_group_add(talk, groupName))\n  printf(\"Listening group %s\\n\", groupName);\nelse\n  fprintf(stderr, \"Failed listen group %s\\n\", groupName);\n```\n\n## mutalk_group_remove\n\n```c\nvoid mutalk_group_remove(mutref talk, const char* name)\n```\nLeave MUTalk group. Do nothing if group not joined\n\n* `mutref talk` MUTalk instance ref\n*  `const char* name` Group name. Maximum lenght defined in MUTALK_MAX_NAME_SIZE. Name can't has spaces\n\n**This function is NOT thread-safe for one MUTalk instance**\n\n## mutalk_send\n\n```c\nvoid mutalk_send(mutref talk, const char *subject,const char * data, size_t size)\n```\nSend message to group.\n\n**Important!** Big messages (more then MTU size) may be corrupted\n(it depends of your network configuration).\n\n* `mutref talk` MUTalk instance ref\n* `const char* name` Group name. Maximum lenght defined in MUTALK_MAX_NAME_SIZE. Name can't has spaces\n* `const char* data` Any data\n* `size_t size` Size of data.\n\n**This function is thread-safe**\n\nExample:\n\n```c\n// See initialization in mutalk_create example\nconst char *message = \"Hello World!\\0\";\nconst char *groupName = \"some.test.group\\0\";\nmutalk_send(talk, groupName, message, strlen(message));\n```\n\n## mutalk_wait\n\n```c\nmutalk_msg_t mutalk_wait(\n  mutref talk,\n  void *buffer,\n  size_t buf_size,\n  int32_t timeout_ms)\n```\nWait message from any joined groups. Returns mutalk_msg_t instance.\n\n* `mutref talk` MUTalk instance ref\n* `void* buffer` Destination buffer.\n* `size_t buf_size` Destination buffer size\n* `int32_t timeout_ms` Timeout in milliseconds. Set -1 for infinity.\nIf no messages received till timeout raised, `msg.error=true` will be set\n\n**This function is NOT thread-safe for one MUTalk instance**\n\nExample:\n\n```c\n// See initialization in mutalk_create example\nconst size_t contentSize = 65535;\nmutalk_msg_t msg;\nchar content[contentSize];\n\nwhile (!(msg = mutalk_wait(talk, content, contentSize, -1)).error) {\n    content[msg.count] = '\\0';\n    printf(\"[%s:%u](%s)\u003c%li bytes\u003e %s\\n\",\n            inet_ntoa(msg.source_ip),\n            msg.source_port,\n            msg.stream-\u003ename,\n            msg.count,\n            content);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freddec%2Fmutalk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freddec%2Fmutalk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freddec%2Fmutalk/lists"}