{"id":16701236,"url":"https://github.com/eproxus/framing","last_synced_at":"2025-08-02T21:03:47.121Z","repository":{"id":36357313,"uuid":"40662095","full_name":"eproxus/framing","owner":"eproxus","description":"Framing provides a prefix length framed net.Conn connection.","archived":false,"fork":false,"pushed_at":"2015-09-24T15:44:36.000Z","size":172,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-09T07:03:39.701Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eproxus.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":"2015-08-13T14:07:23.000Z","updated_at":"2017-11-13T14:05:23.000Z","dependencies_parsed_at":"2022-09-12T23:22:45.101Z","dependency_job_id":null,"html_url":"https://github.com/eproxus/framing","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eproxus/framing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eproxus%2Fframing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eproxus%2Fframing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eproxus%2Fframing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eproxus%2Fframing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eproxus","download_url":"https://codeload.github.com/eproxus/framing/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eproxus%2Fframing/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268454337,"owners_count":24253141,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10-12T18:43:19.149Z","updated_at":"2025-08-02T21:03:47.028Z","avatar_url":"https://github.com/eproxus.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/eproxus/framing.svg)](https://travis-ci.org/eproxus/framing)\n[![Coverage Status](https://coveralls.io/repos/eproxus/framing/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/eproxus/framing?branch=master)\n[![GoDoc](https://godoc.org/github.com/eproxus/framing?status.svg)](https://godoc.org/github.com/eproxus/framing)\n![Go Version](https://img.shields.io/badge/go-1.5-5272B4.svg)\n\n# framing\nFraming provides a prefix length framed net.Conn connection. This is useful if\nyou have connections that send packages that are prefixed with 1, 2 or 4 bytes\nof message length before the actual data.\n\n## Example\n\n```go\npackage main\n\nimport (\n    \"encoding/binary\"\n    \"fmt\"\n    \"log\"\n    \"net\"\n    \"strconv\"\n\n    \"github.com/eproxus/framing\"\n)\n\nconst prefixLength = 4\n\nvar endianess = binary.BigEndian\n\nfunc main() {\n    message := \"13 bytes long\"\n\n    l, err := net.Listen(\"tcp\", \":0\") // Listen on localhost, random port\n    if err != nil {\n        log.Fatal(err)\n    }\n    defer l.Close()\n\n    port := l.Addr().(*net.TCPAddr).Port\n\n    // Send message in a go routine\n    go func() {\n        conn, err := net.Dial(\"tcp\", \":\"+strconv.Itoa(port))\n        if err != nil {\n            log.Fatal(err)\n        }\n\n        framed, err := framing.NewConn(conn, prefixLength, endianess)\n        if err != nil {\n            log.Fatal(err)\n        }\n        defer framed.Close()\n\n        if _, err := fmt.Fprintf(framed, message); err != nil {\n            log.Fatal(err)\n        }\n    }()\n\n    conn, err := l.Accept()\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    framed, err := framing.NewConn(conn, prefixLength, endianess)\n    if err != nil {\n        log.Fatal(err)\n    }\n    defer framed.Close()\n\n    // Receive message\n    frame, err := framed.ReadFrame()\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    fmt.Printf(\"Recieved \\\"%v\\\"\\n\", string(frame[:13]))\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feproxus%2Fframing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feproxus%2Fframing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feproxus%2Fframing/lists"}