SocketType Enumeration

July 28, 2014

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

Namespace:  System.Net.Sockets
Assembly:  System.Net (in System.Net.dll)

public enum SocketType

Member nameDescription
StreamA socket type that 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. This socket type uses the Transmission Control Protocol (Tcp) and the AddressFamily.can be either InterNetwork or InterNetworkV6.
DgramSupports 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 Socket of type Dgram requires no connection prior to sending and receiving data, and can communicate with multiple peers. Dgram uses the Datagram Protocol (Udp) and the InterNetwork or InterNetworkV6AddressFamily. Not a supported value for Windows Phone.
UnknownAn unknown Socket type.

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

NoteNote:

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

Windows Phone OS

Supported in: 8.1, 8.0, 7.1

Windows Phone

Show:
© 2014 Microsoft