github.com/haraldrudell/parl@v0.4.176/parli/socket.go (about) 1 /* 2 © 2022–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/) 3 ISC License 4 */ 5 6 // Package parli provides certain interface declarations. 7 package parli 8 9 import ( 10 "net/netip" 11 12 "github.com/haraldrudell/parl/iana" 13 "github.com/haraldrudell/parl/pids" 14 ) 15 16 // Socket is a representation of a network connection 17 // - may be inbound or outbound 18 // - may be for all interfaces 19 // - only exists for IP protocols 20 // - may be raw socket 21 type Socket interface { 22 // Local is the near ip address and port 23 // - local IP is 0.0.0.0 or :: for wildcard bind 24 // - port is 0 for 24% sendto udp client sockets, which is also possible for tcp 25 // - port is 0 for non-port protocols such as icmp igmp 26 // - broadcast and multicast udp receive is custom 27 Local() (local netip.AddrPort) 28 // Remote is the far IP address and port 29 // - 0.0.0.0:0 or :::0 for listening ports 30 Remote() (remote netip.AddrPort) 31 // Protocol is the IP protocol. Protocol is always present 32 Protocol() (protocol iana.Protocol) 33 // AddressFamily is the type of address used 34 // - It is undefined 0 for 2% few dns connections 35 // - platforms may have proprietary handling of ip46 ports, ie. listening for both IPv4 and IPv6 36 AddressFamily() (addressFamily iana.AddressFamily) 37 // InternetSocket is a near-end quasi-unique identifier 38 // - opaque identifier based on IP, port and protocol 39 // - shared ports, sendto udp clients or non-port protocols may not be unique 40 InternetSocket() (internetSocket iana.InternetSocket) 41 // Pid is the process identifier for the process using the Socket 42 // - Pid is undefined 0 for 26% tcp ports in LISTEN, TIME_WAIT or CLOSED 43 Pid() (pid pids.Pid) 44 }