{"id":17469746,"url":"https://github.com/shellrow/netsock","last_synced_at":"2025-10-24T04:36:22.972Z","repository":{"id":231844419,"uuid":"782853683","full_name":"shellrow/netsock","owner":"shellrow","description":"Cross-platform library for network sockets information","archived":false,"fork":false,"pushed_at":"2025-01-02T13:25:27.000Z","size":89,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-20T00:55:24.189Z","etag":null,"topics":["network","rust","socket"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/shellrow.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}},"created_at":"2024-04-06T08:16:40.000Z","updated_at":"2025-01-03T21:36:50.000Z","dependencies_parsed_at":"2025-01-02T13:30:39.307Z","dependency_job_id":"e25672a8-26e5-4e47-b812-94141fa14e39","html_url":"https://github.com/shellrow/netsock","commit_stats":null,"previous_names":["shellrow/netsock"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shellrow%2Fnetsock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shellrow%2Fnetsock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shellrow%2Fnetsock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shellrow%2Fnetsock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shellrow","download_url":"https://codeload.github.com/shellrow/netsock/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249834786,"owners_count":21331988,"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":["network","rust","socket"],"created_at":"2024-10-18T15:43:40.685Z","updated_at":"2025-10-24T04:36:22.960Z","avatar_url":"https://github.com/shellrow.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[crates-badge]: https://img.shields.io/crates/v/netsock.svg\n[crates-url]: https://crates.io/crates/netsock\n[license-badge]: https://img.shields.io/crates/l/netsock.svg\n[examples-url]: https://github.com/shellrow/netsock/tree/main/examples\n[doc-url]: https://docs.rs/netsock/latest/netsock\n[netsock-github-url]: https://github.com/shellrow/netsock\n\n# netsock [![Crates.io][crates-badge]][crates-url] ![License][license-badge]\nCross-platform library for network sockets information.\n\n## Features\n- Retrieve information for TCP and UDP sockets\n- Support for IPv4 and IPv6\n- Fetch socket information with process info\n\n## Supported platform\n- Linux\n- macOS\n- Windows\n\n## Usage\nAdd `netsock` to your dependencies  \n```toml:Cargo.toml\n[dependencies]\nnetsock = \"0.5\"\n```\n\nFor more details, see [examples][examples-url] or [doc][doc-url].  \n\n## Example\n```rust\nuse netsock::family::AddressFamilyFlags;\nuse netsock::protocol::ProtocolFlags; \nuse netsock::socket::ProtocolSocketInfo;\nuse netsock::get_sockets;\n\nfn main() {\n    // Combine IPv4 and IPv6 address family flags to search for sockets across both families.\n    let af_flags = AddressFamilyFlags::IPV4 | AddressFamilyFlags::IPV6;\n\n    // Combine TCP and UDP protocol flags to search for both types of sockets.\n    let proto_flags = ProtocolFlags::TCP | ProtocolFlags::UDP;\n\n    // Call get_sockets with the specified address family and protocol flags.\n    // This function returns a Result, which we match on to handle both the Ok and Err cases.\n    match get_sockets(af_flags, proto_flags) {\n        Ok(sockets) =\u003e {\n            // If successful, iterate over the returned sockets and print their information.\n            for socket in sockets {\n                // Print the socket and process information\n                match socket.protocol_socket_info {\n                    ProtocolSocketInfo::Tcp(tcp_socket) =\u003e println!(\n                        \"[TCP] {}:{} -\u003e {}:{} {:?} - [{}]\",\n                        tcp_socket.local_addr,\n                        tcp_socket.local_port,\n                        tcp_socket.remote_addr,\n                        tcp_socket.remote_port,\n                        socket.processes,\n                        tcp_socket.state\n                    ),\n                    ProtocolSocketInfo::Udp(udp_socket) =\u003e println!(\n                        \"[UDP] {}:{} -\u003e *:* {:?}\",\n                        udp_socket.local_addr, udp_socket.local_port, socket.processes\n                    ),\n                }\n            }\n        }\n        Err(e) =\u003e {\n            // If an error occurs, print the error message.\n            eprintln!(\"Error: {}\", e);\n        }\n    }\n}\n```\n\n## Inspired by\n- [netstat](https://crates.io/crates/netstat): unmaintained\n- [netstat2](https://crates.io/crates/netstat2)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshellrow%2Fnetsock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshellrow%2Fnetsock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshellrow%2Fnetsock/lists"}