{"id":13732158,"url":"https://github.com/matt-attack/netlibrary","last_synced_at":"2025-05-08T06:31:29.060Z","repository":{"id":18084829,"uuid":"21149229","full_name":"matt-attack/netlibrary","owner":"matt-attack","description":"A simple networking library for C++. Designed with games in mind, but can be used for other things. Tested to work on Android and Windows.","archived":false,"fork":false,"pushed_at":"2016-01-21T17:31:55.000Z","size":45,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-04T02:10:51.903Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/matt-attack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-24T02:16:27.000Z","updated_at":"2024-06-22T04:32:57.000Z","dependencies_parsed_at":"2022-09-24T21:41:49.879Z","dependency_job_id":null,"html_url":"https://github.com/matt-attack/netlibrary","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/matt-attack%2Fnetlibrary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matt-attack%2Fnetlibrary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matt-attack%2Fnetlibrary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matt-attack%2Fnetlibrary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matt-attack","download_url":"https://codeload.github.com/matt-attack/netlibrary/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224707864,"owners_count":17356429,"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-08-03T02:01:47.795Z","updated_at":"2024-11-14T23:31:24.496Z","avatar_url":"https://github.com/matt-attack.png","language":"C++","readme":"Here's the basics of how to use this...\n\nFirst, include the Connection.h file:\n```cpp\n#include \"Netlibrary/Connection.h\"\n```\n\nThen you must open a connection on some port:\n```cpp\nNetConnection connection;\nconnection.Open(5432/*insert your port here*/);\n```\n\nThen you can connect to another server, or just run a message receive loop as shown further down to operate a server.\nThis is a blocking function. It tries to connect 4 times, with a timeout of 1 second each before failing:\n```cpp\nint status = connection.Connect(Address(127,0,0,1,5007), \"password\", 0/*status string pointer if you want*/);\nif (status \u003c 0)\n{\n\t//connection failed\n}\n```\n\nTo receive messages:\n```cpp\nPeer* sender; int size;\nchar* buffer;\nwhile (buffer = connection.Receive(sender, size))\n{\n\t//do stuff with your message\n\t\n\tdelete[] buffer;//delete the message buffer when you are finished with it, or else it leaks\n}\n```\n\nNow, there are four different types of messages that you can send:\n\n- Unreliable, Unsequenced Messages - these may or may not arrive in any order\n- Reliable, Unordered Messages - these are guaranteed to arrive, but can be in any order\n- Reliable, Ordered Messages - these are guaranteed to arrive in the order that they were sent in\n- OOB Messages - these are unreliable messages used primarily for low level commands that are sent immediately\n\n```cpp\n//There are two different ways to send messages, either by specifying the Peer* or not\nnetconnection.SendOOB(char* data, int size);\nnetconnection.SendOOB(Peer* peer, char* data, int size);\n\nnetconnection.Send(char* data, int size);\nnetconnection.Send(Peer* peer, char* data, int size);\n\nnetconnection.SendReliable(char* data, int size);\nnetconnection.SendReliable(Peer* peer, char* data, int size);\n```\n\nYou may access all of the connected peers through the peers std::map\n```cpp\nnetconnection.peers\n```\n","funding_links":[],"categories":["Networking"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatt-attack%2Fnetlibrary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatt-attack%2Fnetlibrary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatt-attack%2Fnetlibrary/lists"}