System.Net.Sockets Namespace

Provides classes that enable low-level network communication.

Classes

Socket Class

Provides the Socket class, which supports unreliable and connectionless message-passing communication.

Constructors

Socket(SocketType, ProtocolType)

public Socket(SocketType socketType, ProtocolType protocolType);

Initializes a new instance of the Socket class using the specified socket type and protocol type.

Methods

Connect(EndPoint)

public void Connect(EndPoint remoteEP);

Establishes a connection to a remote host.

Send(byte[], Int32, Int32, SocketFlags)

public int Send(byte[] buffer, int offset, int size, SocketFlags socketFlags);

Sends the specified number of bytes from the byte array to the remote host.

Receive(byte[], Int32, Int32, SocketFlags)

public int Receive(byte[] buffer, int offset, int size, SocketFlags socketFlags);

Receives data from the remote host into the buffer.

Close()

public void Close();

Releases all resources associated with the Socket.

Enumerations

SocketFlags Enumeration

Specifies socket options for methods such as Socket.Send and Socket.Receive.

None
No flags are set.
Broadcast
Enables broadcast transmission.
Multicast
Enables multicast transmission.
DontRoute
Specifies that the route SHOULD NOT be used to send the datagram. This is a hint to the underlying transport protocols.

SocketOptionLevel Enumeration

Specifies socket options.

Socket
Socket-level options.
IP
IP-level options.
Tcp
TCP-level options.

ProtocolType Enumeration

Specifies the transport protocol.

Tcp
Transmission Control Protocol.
Udp
User Datagram Protocol.
Unknown
An unknown protocol.

SocketType Enumeration

Specifies the type of socket.

Stream
A connection-oriented, reliable, two-way, connection-based byte streams with transmission. Typically TCP.
Dgram
A connectionless, unreliable, two-way datagrams. Typically UDP.
Raw
Raw socket access.

Related Types