SocketProtocol Enum

Specifies the protocols that the Socket class can use.

Enum Members

  • Unknown
    0
    The protocol is not known.
  • Unspecified
    0
    The protocol is not specified.
  • IP
    2
    Internet Protocol.
  • ICMP
    1
    Internet Control Message Protocol.
  • IGMP
    2
    Internet Group Management Protocol.
  • GGP
    3
    Gateway-to-Gateway Protocol.
  • TCP
    6
    Transmission Control Protocol.
  • UDP
    17
    User Datagram Protocol.
  • Raw
    255
    Raw 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