{"id":18406778,"url":"https://github.com/agentcoop/net-dataframe","last_synced_at":"2025-04-12T20:53:41.380Z","repository":{"id":57560412,"uuid":"325858967","full_name":"AgentCoop/net-dataframe","owner":"AgentCoop","description":"A Go library for sending data over TCP networks in frames","archived":false,"fork":false,"pushed_at":"2021-01-13T11:19:01.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T20:53:38.158Z","etag":null,"topics":["frames","go","golang","network-programming","networking","tcp-networks"],"latest_commit_sha":null,"homepage":"","language":"Go","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/AgentCoop.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":"2020-12-31T19:06:50.000Z","updated_at":"2021-01-12T21:02:25.000Z","dependencies_parsed_at":"2022-08-26T05:50:09.997Z","dependency_job_id":null,"html_url":"https://github.com/AgentCoop/net-dataframe","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgentCoop%2Fnet-dataframe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgentCoop%2Fnet-dataframe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgentCoop%2Fnet-dataframe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgentCoop%2Fnet-dataframe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AgentCoop","download_url":"https://codeload.github.com/AgentCoop/net-dataframe/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631724,"owners_count":21136560,"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":["frames","go","golang","network-programming","networking","tcp-networks"],"created_at":"2024-11-06T03:10:47.505Z","updated_at":"2025-04-12T20:53:41.360Z","avatar_url":"https://github.com/AgentCoop.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Preface\nIt's quite often in network programming to send large amount of structured data over TCP networks that do not fit\ninto a single TCP packet, hence there is a strong need to re-assemble received packets into\na single data frame taking into account packet fragmentation. This Go library is meant to\nfacilitate that.\n\n### API\n```go\ntype Receiver interface {\n\t// Captures all available frames in buffer\n\tCapture(buf []byte) ([]*dataFrame, error)\n\t// Resets frame capturing returning captured before data\n\tFlush() []byte\n\t// Returns true if no data were captured\n\tIsEmpty() bool\n}\n\ntype Sender interface {\n\t// Converts data into a frame using gob encoding\n\tToFrame(data interface{}) (*dataFrame, error)\n}\n\ntype DataFrame interface {\n\t// Decodes captured data frame using gob decoder\n\tDecode(receiver interface{}) error\n\n\tGetBytes() []byte\n}\n```\n\n### How to use\n```go\n    //\n    // Client\n    //\n    req := \u0026Request{}\n    req.msg = \"Hello\"\n    \n    // Send your data over wire\n    frame, err := netdataframe.ToFrame(p)\n    if err != nil {\n        panic(err)\n    }\n\n    var n int\n    n, err = conn.Write(frame.GetBytes())\n    ...\n\n    //\n    // Server\n    //\n    // Read network data\n    n, err := conn.Read(readbuf)\n\n    // Capture data frames\n    recv := netdataframe.NewReceiver()\n    frames, err := recv.Capture(readbuf[0:n])\n    // Say hello\n    req := \u0026Request{}\n    err := frames[0].Decode(req)\n    if err != nil { panic(err) }\n    fmt.Printf(req.msg) // hello    \n````\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagentcoop%2Fnet-dataframe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagentcoop%2Fnet-dataframe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagentcoop%2Fnet-dataframe/lists"}