{"id":13563253,"url":"https://github.com/libp2p/go-reuseport","last_synced_at":"2025-04-23T21:00:25.669Z","repository":{"id":26010895,"uuid":"29453505","full_name":"libp2p/go-reuseport","owner":"libp2p","description":"reuse tcp/udp ports in golang","archived":false,"fork":false,"pushed_at":"2025-03-29T08:32:27.000Z","size":155,"stargazers_count":788,"open_issues_count":4,"forks_count":110,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-04-23T20:59:49.731Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/libp2p.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-01-19T04:23:51.000Z","updated_at":"2025-04-20T19:55:55.000Z","dependencies_parsed_at":"2023-07-13T03:34:44.764Z","dependency_job_id":"7e4d7217-a459-495d-a747-2edd8e0c19d4","html_url":"https://github.com/libp2p/go-reuseport","commit_stats":{"total_commits":161,"total_committers":23,"mean_commits":7.0,"dds":0.7453416149068324,"last_synced_commit":"115987a487c41d17a6f5234644017bdb6de04bd2"},"previous_names":["jbenet/go-reuseport"],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libp2p%2Fgo-reuseport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libp2p%2Fgo-reuseport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libp2p%2Fgo-reuseport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libp2p%2Fgo-reuseport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/libp2p","download_url":"https://codeload.github.com/libp2p/go-reuseport/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250514767,"owners_count":21443208,"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-01T13:01:16.893Z","updated_at":"2025-04-23T21:00:25.634Z","avatar_url":"https://github.com/libp2p.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# go-reuseport\n\n[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](https://protocol.ai)\n[![GoDoc](https://godoc.org/github.com/libp2p/go-reuseport?status.svg)](https://godoc.org/github.com/libp2p/go-reuseport)\n[![](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](https://libp2p.io/)\n[![](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](https://webchat.freenode.net/?channels=%23libp2p)\n[![codecov](https://codecov.io/gh/libp2p/go-reuseport/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-reuseport)\n[![Travis CI](https://travis-ci.org/libp2p/go-reuseport.svg?branch=master)](https://travis-ci.org/libp2p/go-reuseport)\n[![Discourse posts](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg)](https://discuss.libp2p.io)\n\nThis package enables listening and dialing from _the same_ TCP or UDP port.\nThis means that the following sockopts may be set:\n\n```\nSO_REUSEADDR\nSO_REUSEPORT\n```\n\nThis is a simple package to help with address reuse. This is particularly\nimportant when attempting to do TCP NAT holepunching, which requires a process\nto both Listen and Dial on the same TCP port. This package provides some\nutilities around enabling this behaviour on various OS.\n\n## Examples\n\n\n```Go\n// listen on the same port. oh yeah.\nl1, _ := reuse.Listen(\"tcp\", \"127.0.0.1:1234\")\nl2, _ := reuse.Listen(\"tcp\", \"127.0.0.1:1234\")\n```\n\n```Go\n// dial from the same port. oh yeah.\nl1, _ := reuse.Listen(\"tcp\", \"127.0.0.1:1234\")\nl2, _ := reuse.Listen(\"tcp\", \"127.0.0.1:1235\")\nc, _ := reuse.Dial(\"tcp\", \"127.0.0.1:1234\", \"127.0.0.1:1235\")\n```\n\n**Note: cant dial self because tcp/ip stacks use 4-tuples to identify connections, and doing so would clash.**\n\n## Tested\n\nTested on `darwin`, `linux`, and `windows`.\n\n---\n\nThe last gx published version of this module was: 0.2.2: Qme8kdM7thoCqLqd7GYCRqipoZJS64rhJo5MBcTpyWfsL9\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibp2p%2Fgo-reuseport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibp2p%2Fgo-reuseport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibp2p%2Fgo-reuseport/lists"}