{"id":13413626,"url":"https://github.com/aerogo/packet","last_synced_at":"2025-09-10T08:32:10.889Z","repository":{"id":57480419,"uuid":"108708663","full_name":"aerogo/packet","owner":"aerogo","description":":package: Send network packets over a TCP or UDP connection.","archived":false,"fork":false,"pushed_at":"2019-11-20T22:35:38.000Z","size":42,"stargazers_count":79,"open_issues_count":1,"forks_count":16,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-29T21:05:49.180Z","etag":null,"topics":["go","network-programming","packet","tcp","udp"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aerogo.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}},"created_at":"2017-10-29T05:46:44.000Z","updated_at":"2024-08-26T09:21:38.000Z","dependencies_parsed_at":"2022-09-18T06:04:25.301Z","dependency_job_id":null,"html_url":"https://github.com/aerogo/packet","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aerogo%2Fpacket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aerogo%2Fpacket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aerogo%2Fpacket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aerogo%2Fpacket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aerogo","download_url":"https://codeload.github.com/aerogo/packet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232518497,"owners_count":18535972,"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":["go","network-programming","packet","tcp","udp"],"created_at":"2024-07-30T20:01:44.846Z","updated_at":"2025-01-04T20:39:47.323Z","avatar_url":"https://github.com/aerogo.png","language":"Go","funding_links":[],"categories":["网络相关库","Networking","网络","Relational Databases"],"sub_categories":["暂未分类","Transliteration","音译","Uncategorized","Strings","交流","Advanced Console UIs","暂未分类这些库被放在这里是因为其他类别似乎都不适合。"],"readme":"# packet\n\n[![Godoc][godoc-image]][godoc-url]\n[![Report][report-image]][report-url]\n[![Tests][tests-image]][tests-url]\n[![Coverage][coverage-image]][coverage-url]\n[![Sponsor][sponsor-image]][sponsor-url]\n\nSend network packets over a TCP or UDP connection.\n\n## Packet\n\nPacket is the main class representing a single network message. It has a byte code indicating the type of the message and a `[]byte` type payload.\n\n## Stream\n\nA stream has a send and receive channel with a hot-swappable connection for reconnects.\nThe user has the responsibility to register a callback to consume errors via `OnError`.\n\n## Example\n\n```go\n// Connect to a server\nconn, _ := net.Dial(\"tcp\", \"localhost:7000\")\n\n// Create a stream\nstream := packet.NewStream(1024)\nstream.SetConnection(conn)\n\n// Send a message\nstream.Outgoing \u003c- packet.New(0, []byte(\"ping\"))\n\n// Receive message\nmsg := \u003c-stream.Incoming\n\n// Check message contents\nif string(msg.Data) != \"pong\" \n```\n\n## Hot-swap example\n\n```go\n// Close server connection to simulate server death\nserver.Close()\n\n// Send packet while server is down (will be buffered until it reconnects)\nclient.Outgoing \u003c- packet.New(0, []byte(\"ping\"))\n\n// Reconnect\nnewServer, _ := net.Dial(\"tcp\", \"localhost:7000\")\n\n// Hot-swap connection\nclient.SetConnection(newServer)\n\n// The previously buffered messages in the Outgoing channel will be sent now.\n```\n\n## Style\n\nPlease take a look at the [style guidelines](https://github.com/akyoto/quality/blob/master/STYLE.md) if you'd like to make a pull request.\n\n## Sponsors\n\n| [![Cedric Fung](https://avatars3.githubusercontent.com/u/2269238?s=70\u0026v=4)](https://github.com/cedricfung) | [![Scott Rayapoullé](https://avatars3.githubusercontent.com/u/11772084?s=70\u0026v=4)](https://github.com/soulcramer) | [![Eduard Urbach](https://avatars3.githubusercontent.com/u/438936?s=70\u0026v=4)](https://twitter.com/eduardurbach) |\n| --- | --- | --- |\n| [Cedric Fung](https://github.com/cedricfung) | [Scott Rayapoullé](https://github.com/soulcramer) | [Eduard Urbach](https://eduardurbach.com) |\n\nWant to see [your own name here?](https://github.com/users/akyoto/sponsorship)\n\n[godoc-image]: https://godoc.org/github.com/aerogo/packet?status.svg\n[godoc-url]: https://godoc.org/github.com/aerogo/packet\n[report-image]: https://goreportcard.com/badge/github.com/aerogo/packet\n[report-url]: https://goreportcard.com/report/github.com/aerogo/packet\n[tests-image]: https://cloud.drone.io/api/badges/aerogo/packet/status.svg\n[tests-url]: https://cloud.drone.io/aerogo/packet\n[coverage-image]: https://codecov.io/gh/aerogo/packet/graph/badge.svg\n[coverage-url]: https://codecov.io/gh/aerogo/packet\n[sponsor-image]: https://img.shields.io/badge/github-donate-green.svg\n[sponsor-url]: https://github.com/users/akyoto/sponsorship\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faerogo%2Fpacket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faerogo%2Fpacket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faerogo%2Fpacket/lists"}