System.Net.Sockets.SocketType Enumeration

Specifies the type of socket that an instance of the System.Net.Sockets.Socket class represents.


public enum SocketType


Before a System.Net.Sockets.Socket can send and receive data, it must first be created using an System.Net.Sockets.AddressFamily, a System.Net.Sockets.SocketType, and a System.Net.Sockets.ProtocolType. The System.Net.Sockets.SocketType enumeration provides several options for defining the type of System.Net.Sockets.Socket that you intend to open.


System.Net.Sockets.SocketType will sometimes implicitly indicate which System.Net.Sockets.ProtocolType will be used within an System.Net.Sockets.AddressFamily. For example when the System.Net.Sockets.SocketType is SocketType.Dgram, the System.Net.Sockets.ProtocolType is always ProtocolType.Udp.When the System.Net.Sockets.SocketType is SocketType.Stream, the System.Net.Sockets.ProtocolType is always ProtocolType.Tcp. If you try to create a System.Net.Sockets.Socket with an incompatible combination, System.Net.Sockets.Socket will throw a System.Net.Sockets.SocketException.


Member NameDescription

Supports datagrams, which are connectionless, unreliable messages of a fixed (typically small) maximum length. Messages might be lost or duplicated and might arrive out of order. A System.Net.Sockets.Socket of type SocketType.Dgram requires no connection prior to sending and receiving data, and can communicate with multiple peers. SocketType.Dgram uses the Datagram Protocol (ProtocolType.Udp) and the AddressFamily.InterNetwork System.Net.Sockets.AddressFamily.


Supports access to the underlying transport protocol. Using the System.Net.Sockets.SocketType SocketType.Raw, you can communicate using protocols like Internet Control Message Protocol (ProtocolType.Icmp) and Internet Group Management Protocol (ProtocolType.Igmp). Your application must provide a complete IP header when sending. Received datagrams return with the IP header and options intact.


Supports connectionless, message-oriented, reliably delivered messages, and preserves message boundaries in data. Rdm (Reliably Delivered Messages) messages arrive unduplicated and in order. Furthermore, the sender is notified if messages are lost. If you initialize a Socket using SocketType.Rdm, you do not require a remote host connection before sending and receiving data. With SocketType.Rdm, you can communicate with multiple peers.


Provides connection-oriented and reliable two-way transfer of ordered byte streams across a network. SocketType.Seqpacket does not duplicate data, and it preserves boundaries within the data stream. A Socket of type SocketType.Seqpacket communicates with a single peer and requires a remote host connection before communication can begin.


Supports reliable, two-way, connection-based byte streams without the duplication of data and without preservation of boundaries. A Socket of this type communicates with a single peer and requires a remote host connection before communication can begin. SocketType.Stream uses the Transmission Control Protocol (ProtocolType.Tcp) System.Net.Sockets.ProtocolType and the InterNetwork System.Net.Sockets.AddressFamily.


Specifies an unknown Socket type.


Namespace: System.Net.Sockets
Assembly: System (in System.dll)
Assembly Versions: 1.0.x.x, 1.0.5000.0,,