github.com/haraldrudell/parl@v0.4.176/pnet/socket-transport.go (about) 1 /* 2 © 2021–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/) 3 ISC License 4 */ 5 6 package pnet 7 8 import "github.com/haraldrudell/parl/sets" 9 10 // SocketTransport describes what type of socket from the types supported by Go 11 // - TransportTCP TransportUDP TransportIP TransportUnix 12 // - 0 is uninitalized invalid 13 type SocketTransport uint8 14 15 const ( 16 // tcp connection oriented 17 // - listener implementation is *net.TCPListener 18 // - network is tcp tcp4 tcp6 19 // - netListener.Addr implementation is *net.TCPAddr 20 TransportTCP = iota + 1 21 // udp connectionless 22 TransportUDP 23 // ip: no port: protocols like icmp 24 TransportIP 25 // Unix socket inside the kernel to a process on the same host 26 TransportUnix 27 ) 28 29 func (t SocketTransport) String() (s string) { 30 return transportSet.StringT(t) 31 } 32 33 // IsValid returns true if the SocketTransport has been initialized 34 func (t SocketTransport) IsValid() (isValid bool) { 35 return transportSet.IsValid(t) 36 } 37 38 // transportSet is the set variable for SocketTransport 39 var transportSet = sets.NewSet[SocketTransport]([]sets.SetElement[SocketTransport]{ 40 {ValueV: TransportTCP, Name: "tcp"}, 41 })