SocketProtocol Enum
Specifies the protocols that the Socket class can use.
Enum Members
-
Unknown0The protocol is not known.
-
Unspecified0The protocol is not specified.
-
IP2Internet Protocol.
-
ICMP1Internet Control Message Protocol.
-
IGMP2Internet Group Management Protocol.
-
GGP3Gateway-to-Gateway Protocol.
-
TCP6Transmission Control Protocol.
-
UDP17User Datagram Protocol.
-
Raw255Raw IP packets.
Remarks
The SocketProtocol enumeration defines the protocols supported by the Socket class. When you create a Socket, you specify the address family (e.g., AddressFamily.InterNetwork for IPv4) and the socket type (e.g., SocketType.Stream for TCP or SocketType.Dgram for UDP). The protocol is usually implicitly determined by the socket type, but can also be explicitly specified using this enumeration.
For example, to create a TCP socket, you would typically use:
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
While Unknown and Unspecified both have a value of 0, they represent slightly different states. Unknown implies that the protocol is not recognized or supported by the system, whereas Unspecified means that the protocol has not been explicitly set and might be determined by default settings.
See Also
- Socket class
- SocketType enumeration
- AddressFamily enumeration
- System.Net.Sockets Namespace