Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​Net.​Sockets.​Socket
Assembly: System.Net.Sockets
Inheritance: object → Socket
Implemented Interfaces
Implements the Berkeley sockets interface.
Properties
public
AddressFamily
AddressFamily
Gets the address family of the <see cref="T:System.Net.Sockets.Socket" /> .
public
int
Available
Gets the amount of data that has been received from the network and is available to be read.
public
bool
Blocking
Gets or sets a value that indicates whether the <see cref="T:System.Net.Sockets.Socket" /> is in blocking mode.
public
bool
Connected
Gets a value that indicates whether a <see cref="T:System.Net.Sockets.Socket" /> is connected to a remote host as of the last <see cref="Overload:System.Net.Sockets.Socket.Send" /> or <see cref="Overload:System.Net.Sockets.Socket.Receive" /> operation.
public
bool
DontFragment
Gets or sets a value that specifies whether the <see cref="T:System.Net.Sockets.Socket" /> allows Internet Protocol (IP) datagrams to be fragmented.
public
bool
DualMode
Gets or sets a value that specifies whether the <see cref="T:System.Net.Sockets.Socket" /> is a dual-mode socket used for both IPv4 and IPv6.
public
bool
EnableBroadcast
Gets or sets a <see cref="T:System.Boolean" /> value that specifies whether the <see cref="T:System.Net.Sockets.Socket" /> can send broadcast packets.
public
bool
ExclusiveAddressUse
Gets or sets a value that indicates whether the <see cref="T:System.Net.Sockets.Socket" /> allows only one process to bind to a port.
public
nint
Handle
Gets the operating system handle for the <see cref="T:System.Net.Sockets.Socket" /> .
public
bool
IsBound
Gets a value that indicates whether the <see cref="T:System.Net.Sockets.Socket" /> is bound to a specific local port.
public
LingerOption
LingerState
Gets or sets a value that specifies whether the <see cref="T:System.Net.Sockets.Socket" /> will delay closing a socket in an attempt to send all pending data.
public
EndPoint
LocalEndPoint
Gets the local endpoint.
public
bool
MulticastLoopback
Gets or sets a value that specifies whether outgoing multicast packets are delivered to the sending application.
public
bool
NoDelay
Gets or sets a <see cref="T:System.Boolean" /> value that specifies whether the stream <see cref="T:System.Net.Sockets.Socket" /> is using the Nagle algorithm.
public static
bool
OSSupportsIPv4
Indicates whether the underlying operating system and network adaptors support Internet Protocol version 4 (IPv4).
public static
bool
OSSupportsIPv6
Indicates whether the underlying operating system and network adaptors support Internet Protocol version 6 (IPv6).
public static
bool
OSSupportsUnixDomainSockets
Indicates whether the underlying operating system support the Unix domain sockets.
public
ProtocolType
ProtocolType
Gets the protocol type of the <see cref="T:System.Net.Sockets.Socket" /> .
public
int
ReceiveBufferSize
Gets or sets a value that specifies the size of the receive buffer of the <see cref="T:System.Net.Sockets.Socket" /> .
public
int
ReceiveTimeout
Gets or sets a value that specifies the amount of time after which a synchronous <see cref="Overload:System.Net.Sockets.Socket.Receive" /> call will time out.
public
EndPoint
RemoteEndPoint
Gets the remote endpoint.
public
SafeSocketHandle
SafeHandle
Gets a <see cref="T:System.Net.Sockets.SafeSocketHandle" /> that represents the socket handle that the current <see cref="T:System.Net.Sockets.Socket" /> object encapsulates.
public
int
SendBufferSize
Gets or sets a value that specifies the size of the send buffer of the <see cref="T:System.Net.Sockets.Socket" /> .
public
int
SendTimeout
Gets or sets a value that specifies the amount of time after which a synchronous <see cref="Overload:System.Net.Sockets.Socket.Send" /> call will time out.
public
SocketType
SocketType
Gets the type of the <see cref="T:System.Net.Sockets.Socket" /> .
public static
bool
SupportsIPv4
Gets a value indicating whether IPv4 support is available and enabled on the current host.
public static
bool
SupportsIPv6
Gets a value that indicates whether the Framework supports IPv6 for certain obsolete <see cref="T:System.Net.Dns" /> members.
public
short
Ttl
Gets or sets a value that specifies the Time To Live (TTL) value of Internet Protocol (IP) packets sent by the <see cref="T:System.Net.Sockets.Socket" /> .
public
bool
UseOnlyOverlappedIO
Gets or sets a value that specifies whether the socket should only use Overlapped I/O mode. On .NET 5+ (including .NET Core versions), the value is always <see langword="false" /> .
Methods
public
Socket
Accept​()
Creates a new <see cref="T:System.Net.Sockets.Socket" /> for a newly created connection.
Returns A <see cref="T:System.Net.Sockets.Socket" /> for a newly created connection.
public
Threading.​Tasks.​Task<​Socket>
AcceptAsync​()
Accepts an incoming connection.
Returns An asynchronous task that completes with the accepted Socket.
public
Threading.​Tasks.​Task<​Socket>
AcceptAsync​(Socket? acceptSocket)
Accepts an incoming connection.
Returns An asynchronous task that completes with the accepted Socket.
acceptSocket
The socket to use for accepting the connection.
public
Threading.​Tasks.​ValueTask<​Socket>
AcceptAsync​(Socket acceptSocket,
Threading.​CancellationToken cancellationToken)
Accepts an incoming connection.
Returns An asynchronous task that completes with the accepted Socket.
acceptSocket
The socket to use for accepting the connection.
cancellationToken
A cancellation token that can be used to cancel the asynchronous operation.
public
bool
AcceptAsync​(SocketAsyncEventArgs e)
Begins an asynchronous operation to accept an incoming connection attempt.
Returns <see langword="true" /> if the I/O operation is pending. The <see cref="E:System.Net.Sockets.SocketAsyncEventArgs.Completed" /> event on the <paramref name="e" /> parameter will be raised upon completion of the operation.
<see langword="false" /> if the I/O operation completed synchronously. The <see cref="E:System.Net.Sockets.SocketAsyncEventArgs.Completed" /> event on the <paramref name="e" /> parameter will not be raised and the <paramref name="e" /> object passed as a parameter may be examined immediately after the method call returns to retrieve the result of the operation.
e
The <see cref="T:System.Net.Sockets.SocketAsyncEventArgs" /> object to use for this asynchronous socket operation.
public
Threading.​Tasks.​ValueTask<​Socket>
AcceptAsync​(Threading.​CancellationToken cancellationToken)
Accepts an incoming connection.
Returns An asynchronous task that completes with the accepted Socket.
cancellationToken
A cancellation token that can be used to cancel the asynchronous operation.
public
IAsyncResult
BeginAccept​(AsyncCallback callback,
object state)
Begins an asynchronous operation to accept an incoming connection attempt.
Returns An <see cref="T:System.IAsyncResult" /> that references the asynchronous <see cref="T:System.Net.Sockets.Socket" /> creation.
callback
The <see cref="T:System.AsyncCallback" /> delegate.
state
An object that contains state information for this request.
public
IAsyncResult
BeginAccept​(int receiveSize,
AsyncCallback callback,
object state)
Begins an asynchronous operation to accept an incoming connection attempt and receives the first block of data sent by the client application.
Returns An <see cref="T:System.IAsyncResult" /> that references the asynchronous <see cref="T:System.Net.Sockets.Socket" /> creation.
receiveSize
The number of bytes to accept from the sender.
callback
The <see cref="T:System.AsyncCallback" /> delegate.
state
An object that contains state information for this request.
public
IAsyncResult
BeginAccept​(Socket acceptSocket,
int receiveSize,
AsyncCallback callback,
object state)
Begins an asynchronous operation to accept an incoming connection attempt from a specified socket and receives the first block of data sent by the client application.
Returns An <see cref="T:System.IAsyncResult" /> object that references the asynchronous <see cref="T:System.Net.Sockets.Socket" /> object creation.
acceptSocket
The accepted <see cref="T:System.Net.Sockets.Socket" /> object. This value may be <see langword="null" /> .
receiveSize
The maximum number of bytes to receive.
callback
The <see cref="T:System.AsyncCallback" /> delegate.
state
An object that contains state information for this request.
public
IAsyncResult
BeginConnect​(EndPoint remoteEP,
AsyncCallback? callback,
object state)
Begins an asynchronous request for a remote host connection.
Returns An <see cref="T:System.IAsyncResult" /> that references the asynchronous connection.
remoteEP
An <see cref="T:System.Net.EndPoint" /> that represents the remote host.
callback
The <see cref="T:System.AsyncCallback" /> delegate.
state
An object that contains state information for this request.
public
IAsyncResult
BeginConnect​(IPAddress address,
int port,
AsyncCallback? requestCallback,
object state)
Begins an asynchronous request for a remote host connection. The host is specified by an <see cref="T:System.Net.IPAddress" /> and a port number.
Returns An <see cref="T:System.IAsyncResult" /> that references the asynchronous connection.
address
The <see cref="T:System.Net.IPAddress" /> of the remote host.
port
The port number of the remote host.
requestCallback
An <see cref="T:System.AsyncCallback" /> delegate that references the method to invoke when the connect operation is complete.
state
A user-defined object that contains information about the connect operation. This object is passed to the <paramref name="requestCallback" /> delegate when the operation is complete.
public
IAsyncResult
BeginConnect​(IPAddress[] addresses,
int port,
AsyncCallback? requestCallback,
object state)
Begins an asynchronous request for a remote host connection. The host is specified by an <see cref="T:System.Net.IPAddress" /> array and a port number.
Returns An <see cref="T:System.IAsyncResult" /> that references the asynchronous connections.
addresses
At least one <see cref="T:System.Net.IPAddress" /> , designating the remote host.
port
The port number of the remote host.
requestCallback
An <see cref="T:System.AsyncCallback" /> delegate that references the method to invoke when the connect operation is complete.
state
A user-defined object that contains information about the connect operation. This object is passed to the <paramref name="requestCallback" /> delegate when the operation is complete.
public
IAsyncResult
BeginConnect​(string host,
int port,
AsyncCallback? requestCallback,
object state)
Begins an asynchronous request for a remote host connection. The host is specified by a host name and a port number.
Returns An <see cref="T:System.IAsyncResult" /> that references the asynchronous connection.
host
The name of the remote host.
port
The port number of the remote host.
requestCallback
An <see cref="T:System.AsyncCallback" /> delegate that references the method to invoke when the connect operation is complete.
state
A user-defined object that contains information about the connect operation. This object is passed to the <paramref name="requestCallback" /> delegate when the operation is complete.
public
IAsyncResult
BeginDisconnect​(bool reuseSocket,
AsyncCallback callback,
object state)
Begins an asynchronous request to disconnect from a remote endpoint.
Returns An <see cref="T:System.IAsyncResult" /> object that references the asynchronous operation.
reuseSocket
<see langword="true" /> if this socket can be reused after the connection is closed; otherwise, <see langword="false" /> .
callback
The <see cref="T:System.AsyncCallback" /> delegate.
state
An object that contains state information for this request.
public
IAsyncResult
BeginReceive​(byte[] buffer,
int offset,
int size,
SocketFlags socketFlags,
AsyncCallback? callback,
object state)
Begins to asynchronously receive data from a connected <see cref="T:System.Net.Sockets.Socket" /> .
Returns An <see cref="T:System.IAsyncResult" /> that references the asynchronous read.
buffer
An array of type <see cref="T:System.Byte" /> that is the storage location for the received data.
offset
The zero-based position in the <paramref name="buffer" /> parameter at which to store the received data.
size
The number of bytes to receive.
socketFlags
A bitwise combination of the <see cref="T:System.Net.Sockets.SocketFlags" /> values.
callback
An <see cref="T:System.AsyncCallback" /> delegate that references the method to invoke when the operation is complete.
state
A user-defined object that contains information about the receive operation. This object is passed to the <see cref="M:System.Net.Sockets.Socket.EndReceive(System.IAsyncResult)" /> delegate when the operation is complete.
public
IAsyncResult
BeginReceive​(byte[] buffer,
int offset,
int size,
SocketFlags socketFlags,
SocketError& errorCode,
AsyncCallback callback,
object state)
public
IAsyncResult
BeginReceive​(Collections.​Generic.​IList<​ArraySegment<​byte>> buffers,
SocketFlags socketFlags,
AsyncCallback callback,
object state)
Begins to asynchronously receive data from a connected <see cref="T:System.Net.Sockets.Socket" /> .
Returns An <see cref="T:System.IAsyncResult" /> that references the asynchronous read.
buffers
An array of type <see cref="T:System.Byte" /> that is the storage location for the received data.
socketFlags
A bitwise combination of the <see cref="T:System.Net.Sockets.SocketFlags" /> values.
callback
An <see cref="T:System.AsyncCallback" /> delegate that references the method to invoke when the operation is complete.
state
A user-defined object that contains information about the receive operation. This object is passed to the <see cref="M:System.Net.Sockets.Socket.EndReceive(System.IAsyncResult)" /> delegate when the operation is complete.
public
IAsyncResult
BeginReceive​(Collections.​Generic.​IList<​ArraySegment<​byte>> buffers,
SocketFlags socketFlags,
SocketError& errorCode,
AsyncCallback callback,
object state)
public
IAsyncResult
BeginReceiveFrom​(byte[] buffer,
int offset,
int size,
SocketFlags socketFlags,
EndPoint& remoteEP,
AsyncCallback? callback,
object state)
public
IAsyncResult
BeginReceiveMessageFrom​(byte[] buffer,
int offset,
int size,
SocketFlags socketFlags,
EndPoint& remoteEP,
AsyncCallback? callback,
object state)
public
IAsyncResult
BeginSend​(byte[] buffer,
int offset,
int size,
SocketFlags socketFlags,
AsyncCallback? callback,
object state)
Sends data asynchronously to a connected <see cref="T:System.Net.Sockets.Socket" /> .
Returns An <see cref="T:System.IAsyncResult" /> that references the asynchronous send.
buffer
An array of type <see cref="T:System.Byte" /> that contains the data to send.
offset
The zero-based position in the <paramref name="buffer" /> parameter at which to begin sending data.
size
The number of bytes to send.
socketFlags
A bitwise combination of the <see cref="T:System.Net.Sockets.SocketFlags" /> values.
callback
The <see cref="T:System.AsyncCallback" /> delegate.
state
An object that contains state information for this request.
public
IAsyncResult
BeginSend​(byte[] buffer,
int offset,
int size,
SocketFlags socketFlags,
SocketError& errorCode,
AsyncCallback callback,
object state)
public
IAsyncResult
BeginSend​(Collections.​Generic.​IList<​ArraySegment<​byte>> buffers,
SocketFlags socketFlags,
AsyncCallback callback,
object state)
Sends data asynchronously to a connected <see cref="T:System.Net.Sockets.Socket" /> .
Returns An <see cref="T:System.IAsyncResult" /> that references the asynchronous send.
buffers
An array of type <see cref="T:System.Byte" /> that contains the data to send.
socketFlags
A bitwise combination of the <see cref="T:System.Net.Sockets.SocketFlags" /> values.
callback
The <see cref="T:System.AsyncCallback" /> delegate.
state
An object that contains state information for this request.
public
IAsyncResult
BeginSend​(Collections.​Generic.​IList<​ArraySegment<​byte>> buffers,
SocketFlags socketFlags,
SocketError& errorCode,
AsyncCallback callback,
object state)
public
IAsyncResult
BeginSendFile​(string fileName,
AsyncCallback callback,
object state)
Sends the file <paramref name="fileName" /> to a connected <see cref="T:System.Net.Sockets.Socket" /> object using the <see cref="F:System.Net.Sockets.TransmitFileOptions.UseDefaultWorkerThread" /> flag.
Returns An <see cref="T:System.IAsyncResult" /> object that represents the asynchronous send.
fileName
A string that contains the path and name of the file to send. This parameter can be <see langword="null" /> .
callback
The <see cref="T:System.AsyncCallback" /> delegate.
state
An object that contains state information for this request.
public
IAsyncResult
BeginSendFile​(string fileName,
byte[] preBuffer,
byte[] postBuffer,
TransmitFileOptions flags,
AsyncCallback callback,
object state)
Sends a file and buffers of data asynchronously to a connected <see cref="T:System.Net.Sockets.Socket" /> object.
Returns An <see cref="T:System.IAsyncResult" /> object that represents the asynchronous operation.
fileName
A string that contains the path and name of the file to be sent. This parameter can be <see langword="null" /> .
preBuffer
The data to be sent before the file is sent. This parameter can be <see langword="null" /> .
postBuffer
The data to be sent after the file is sent. This parameter can be <see langword="null" /> .
flags
A bitwise combination of the enumeration values.
callback
An <see cref="T:System.AsyncCallback" /> delegate to be invoked when this operation completes. This parameter can be <see langword="null" /> .
state
A user-defined object that contains state information for this request. This parameter can be <see langword="null" /> .
public
IAsyncResult
BeginSendTo​(byte[] buffer,
int offset,
int size,
SocketFlags socketFlags,
EndPoint remoteEP,
AsyncCallback? callback,
object state)
Sends data asynchronously to a specific remote host.
Returns An <see cref="T:System.IAsyncResult" /> that references the asynchronous send.
buffer
An array of type <see cref="T:System.Byte" /> that contains the data to send.
offset
The zero-based position in <paramref name="buffer" /> at which to begin sending data.
size
The number of bytes to send.
socketFlags
A bitwise combination of the <see cref="T:System.Net.Sockets.SocketFlags" /> values.
remoteEP
An <see cref="T:System.Net.EndPoint" /> that represents the remote device.
callback
The <see cref="T:System.AsyncCallback" /> delegate.
state
An object that contains state information for this request.
public
void
Bind​(EndPoint localEP)
Associates a <see cref="T:System.Net.Sockets.Socket" /> with a local endpoint.
localEP
The local <see cref="T:System.Net.EndPoint" /> to associate with the <see cref="T:System.Net.Sockets.Socket" /> .
public static
void
CancelConnectAsync​(SocketAsyncEventArgs e)
Cancels an asynchronous request for a remote host connection.
e
The <see cref="T:System.Net.Sockets.SocketAsyncEventArgs" /> object used to request the connection to the remote host by calling one of the <see cref="M:System.Net.Sockets.Socket.ConnectAsync(System.Net.Sockets.SocketType,System.Net.Sockets.ProtocolType,System.Net.Sockets.SocketAsyncEventArgs)" /> methods.
public
void
Close​()
Closes the <see cref="T:System.Net.Sockets.Socket" /> connection and releases all associated resources.
public
void
Close​(int timeout)
Closes the <see cref="T:System.Net.Sockets.Socket" /> connection and releases all associated resources with a specified timeout to allow queued data to be sent.
timeout
Wait up to <paramref name="timeout" /> milliseconds to send any remaining data, then close the socket.
remoteEP
An <see cref="T:System.Net.EndPoint" /> that represents the remote device.
public
void
Connect​(IPAddress address,
int port)
Establishes a connection to a remote host. The host is specified by an IP address and a port number.
address
The IP address of the remote host.
port
The port number of the remote host.
public
void
Connect​(IPAddress[] addresses,
int port)
Establishes a connection to a remote host. The host is specified by an array of IP addresses and a port number.
addresses
The IP addresses of the remote host.
port
The port number of the remote host.
public
void
Connect​(string host,
int port)
Establishes a connection to a remote host. The host is specified by a host name and a port number.
host
The name of the remote host.
port
The port number of the remote host.
Returns An asynchronous task that completes when the connection is established.
remoteEP
The endpoint to connect to.
ConnectAsync​(EndPoint remoteEP,
Threading.​CancellationToken cancellationToken)
Establishes a connection to a remote host.
Returns An asynchronous task that completes when the connection is established.
remoteEP
The endpoint to connect to.
cancellationToken
A cancellation token that can be used to cancel the asynchronous operation.
ConnectAsync​(IPAddress address,
int port)
Establishes a connection to a remote host.
Returns An asynchronous task that completes when the connection is established.
address
The IPAddress of the remote host to connect to.
port
The port on the remote host to connect to.
ConnectAsync​(IPAddress address,
int port,
Threading.​CancellationToken cancellationToken)
Establishes a connection to a remote host.
Returns An asynchronous task that completes when the connection is established.
address
The IPAddress of the remote host to connect to.
port
The port on the remote host to connect to.
cancellationToken
A cancellation token that can be used to cancel the asynchronous operation.
ConnectAsync​(IPAddress[] addresses,
int port)
Establishes a connection to a remote host.
Returns An asynchronous task that completes when the connection is established.
addresses
A list of IPAddresses for the remote host that will be used to attempt to connect to the remote host.
port
The port on the remote host to connect to.
ConnectAsync​(IPAddress[] addresses,
int port,
Threading.​CancellationToken cancellationToken)
Establishes a connection to a remote host.
Returns An asynchronous task that completes when the connection is established.
addresses
A list of IPAddresses for the remote host that will be used to attempt to connect to the remote host.
port
The port on the remote host to connect to.
cancellationToken
A cancellation token that can be used to cancel the asynchronous operation.
public
bool
ConnectAsync​(SocketAsyncEventArgs e)
Begins an asynchronous request for a connection to a remote host.
Returns <see langword="true" /> if the I/O operation is pending. The <see cref="E:System.Net.Sockets.SocketAsyncEventArgs.Completed" /> event on the <paramref name="e" /> parameter will be raised upon completion of the operation.
<see langword="false" /> if the I/O operation completed synchronously. In this case, The <see cref="E:System.Net.Sockets.SocketAsyncEventArgs.Completed" /> event on the <paramref name="e" /> parameter will not be raised and the <paramref name="e" /> object passed as a parameter may be examined immediately after the method call returns to retrieve the result of the operation.
e
The <see cref="T:System.Net.Sockets.SocketAsyncEventArgs" /> object to use for this asynchronous socket operation.
public static
bool
ConnectAsync​(SocketType socketType,
ProtocolType protocolType,
SocketAsyncEventArgs e)
Begins an asynchronous request for a connection to a remote host.
Returns <see langword="true" /> if the I/O operation is pending. The <see cref="E:System.Net.Sockets.SocketAsyncEventArgs.Completed" /> event on the <paramref name="e" /> parameter will be raised upon completion of the operation.
<see langword="false" /> if the I/O operation completed synchronously. In this case, The <see cref="E:System.Net.Sockets.SocketAsyncEventArgs.Completed" /> event on the <paramref name="e" /> parameter will not be raised and the <paramref name="e" /> object passed as a parameter may be examined immediately after the method call returns to retrieve the result of the operation.
socketType
One of the <see cref="T:System.Net.Sockets.SocketType" /> values.
protocolType
One of the <see cref="T:System.Net.Sockets.ProtocolType" /> values.
e
The <see cref="T:System.Net.Sockets.SocketAsyncEventArgs" /> object to use for this asynchronous socket operation.
ConnectAsync​(string host,
int port)
Establishes a connection to a remote host.
Returns An asynchronous task that completes when the connection is established.
host
The hostname of the remote host to connect to.
port
The port on the remote host to connect to.
ConnectAsync​(string host,
int port,
Threading.​CancellationToken cancellationToken)
Establishes a connection to a remote host.
Returns An asynchronous task that completes when the connection is established.
host
The hostname of the remote host to connect to.
port
The port on the remote host to connect to.
cancellationToken
A cancellation token that can be used to cancel the asynchronous operation.
public
void
Disconnect​(bool reuseSocket)
Closes the socket connection and allows reuse of the socket.
reuseSocket
<see langword="true" /> if this socket can be reused after the current connection is closed; otherwise, <see langword="false" /> .
DisconnectAsync​(bool reuseSocket,
Threading.​CancellationToken cancellationToken = null)
Disconnects a connected socket from the remote host.
Returns An asynchronous task that completes when the socket is disconnected.
reuseSocket
Indicates whether the socket should be available for reuse after disconnect.
cancellationToken
A cancellation token that can be used to cancel the asynchronous operation.
public
bool
DisconnectAsync​(SocketAsyncEventArgs e)
Begins an asynchronous request to disconnect from a remote endpoint.
Returns <see langword="true" /> if the I/O operation is pending. The <see cref="E:System.Net.Sockets.SocketAsyncEventArgs.Completed" /> event on the <paramref name="e" /> parameter will be raised upon completion of the operation.
<see langword="false" /> if the I/O operation completed synchronously. In this case, The <see cref="E:System.Net.Sockets.SocketAsyncEventArgs.Completed" /> event on the <paramref name="e" /> parameter will not be raised and the <paramref name="e" /> object passed as a parameter may be examined immediately after the method call returns to retrieve the result of the operation.
e
The <see cref="T:System.Net.Sockets.SocketAsyncEventArgs" /> object to use for this asynchronous socket operation.
public
void
Dispose​()
Releases all resources used by the current instance of the <see cref="T:System.Net.Sockets.Socket" /> class.
protected
void
Dispose​(bool disposing)
Releases the unmanaged resources used by the <see cref="T:System.Net.Sockets.Socket" /> , and optionally disposes of the managed resources.
disposing
<see langword="true" /> to release both managed and unmanaged resources; <see langword="false" /> to releases only unmanaged resources.
public
SocketInformation
DuplicateAndClose​(int targetProcessId)
Duplicates the socket reference for the target process, and closes the socket for this process.
Returns The socket reference to be passed to the target process.
targetProcessId
The ID of the target process where a duplicate of the socket reference is created.
public
Socket
EndAccept​(Byte[]& buffer,
Int32& bytesTransferred,
IAsyncResult asyncResult)
public
Socket
EndAccept​(IAsyncResult asyncResult)
Asynchronously accepts an incoming connection attempt and creates a new <see cref="T:System.Net.Sockets.Socket" /> to handle remote host communication.
Returns A <see cref="T:System.Net.Sockets.Socket" /> to handle communication with the remote host.
asyncResult
An <see cref="T:System.IAsyncResult" /> that stores state information for this asynchronous operation as well as any user defined data.
public
void
EndConnect​(IAsyncResult asyncResult)
Ends a pending asynchronous connection request.
asyncResult
An <see cref="T:System.IAsyncResult" /> that stores state information and any user defined data for this asynchronous operation.
public
void
EndDisconnect​(IAsyncResult asyncResult)
Ends a pending asynchronous disconnect request.
asyncResult
An <see cref="T:System.IAsyncResult" /> object that stores state information and any user-defined data for this asynchronous operation.
Returns The total number of bytes received. The method returns zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown. If zero bytes are requested, receive operations may complete immediately or may not complete until at least one byte is available (but without consuming any data).
asyncResult
An <see cref="T:System.IAsyncResult" /> that stores state information and any user defined data for this asynchronous operation.
public
int
EndReceiveMessageFrom​(IAsyncResult asyncResult,
SocketFlags& socketFlags,
EndPoint& endPoint,
IPPacketInformation& ipPacketInformation)
Returns If successful, the number of bytes sent to the <see cref="T:System.Net.Sockets.Socket" /> ; otherwise, an invalid <see cref="T:System.Net.Sockets.Socket" /> error.
asyncResult
An <see cref="T:System.IAsyncResult" /> that stores state information for this asynchronous operation.
public
void
EndSendFile​(IAsyncResult asyncResult)
Ends a pending asynchronous send of a file.
asyncResult
An <see cref="T:System.IAsyncResult" /> object that stores state information for this asynchronous operation.
public
int
EndSendTo​(IAsyncResult asyncResult)
Ends a pending asynchronous send to a specific location.
Returns If successful, the number of bytes sent; otherwise, an invalid <see cref="T:System.Net.Sockets.Socket" /> error.
asyncResult
An <see cref="T:System.IAsyncResult" /> that stores state information and any user defined data for this asynchronous operation.
protected
void
Finalize​()
Frees resources used by the <see cref="T:System.Net.Sockets.Socket" /> class.
public
int
GetRawSocketOption​(int optionLevel,
int optionName,
Span<​byte> optionValue)
Gets a socket option value using platform-specific level and name identifiers.
Returns The number of bytes written into <paramref name="optionValue" /> for a successfully retrieved value.
optionLevel
The platform-defined option level.
optionName
The platform-defined option name.
optionValue
The span into which the retrieved option value should be stored.
public
object
GetSocketOption​(SocketOptionLevel optionLevel,
SocketOptionName optionName)
Returns the value of a specified <see cref="T:System.Net.Sockets.Socket" /> option, represented as an object.
Returns An object that represents the value of the option. When the <paramref name="optionName" /> parameter is set to <see cref="F:System.Net.Sockets.SocketOptionName.Linger" /> the return value is an instance of the <see cref="T:System.Net.Sockets.LingerOption" /> class. When <paramref name="optionName" /> is set to <see cref="F:System.Net.Sockets.SocketOptionName.AddMembership" /> or <see cref="F:System.Net.Sockets.SocketOptionName.DropMembership" /> , the return value is an instance of the <see cref="T:System.Net.Sockets.MulticastOption" /> class. When <paramref name="optionName" /> is any other value, the return value is an integer.
optionLevel
One of the <see cref="T:System.Net.Sockets.SocketOptionLevel" /> values.
optionName
One of the <see cref="T:System.Net.Sockets.SocketOptionName" /> values.
public
void
GetSocketOption​(SocketOptionLevel optionLevel,
SocketOptionName optionName,
byte[] optionValue)
Returns the specified <see cref="T:System.Net.Sockets.Socket" /> option setting, represented as a byte array.
optionLevel
One of the <see cref="T:System.Net.Sockets.SocketOptionLevel" /> values.
optionName
One of the <see cref="T:System.Net.Sockets.SocketOptionName" /> values.
optionValue
An array of type <see cref="T:System.Byte" /> that is to receive the option setting.
public
byte[]
GetSocketOption​(SocketOptionLevel optionLevel,
SocketOptionName optionName,
int optionLength)
Returns the value of the specified <see cref="T:System.Net.Sockets.Socket" /> option in an array.
Returns An array of type <see cref="T:System.Byte" /> that contains the value of the socket option.
optionLevel
One of the <see cref="T:System.Net.Sockets.SocketOptionLevel" /> values.
optionName
One of the <see cref="T:System.Net.Sockets.SocketOptionName" /> values.
optionLength
The length, in bytes, of the expected return value.
public
int
IOControl​(int ioControlCode,
byte[] optionInValue,
byte[] optionOutValue)
Sets low-level operating modes for the <see cref="T:System.Net.Sockets.Socket" /> using numerical control codes.
Returns The number of bytes in the <paramref name="optionOutValue" /> parameter.
ioControlCode
An <see cref="T:System.Int32" /> value that specifies the control code of the operation to perform.
optionInValue
A <see cref="T:System.Byte" /> array that contains the input data required by the operation.
optionOutValue
A <see cref="T:System.Byte" /> array that contains the output data returned by the operation.
public
int
IOControl​(IOControlCode ioControlCode,
byte[] optionInValue,
byte[] optionOutValue)
Sets low-level operating modes for the <see cref="T:System.Net.Sockets.Socket" /> using the <see cref="T:System.Net.Sockets.IOControlCode" /> enumeration to specify control codes.
Returns The number of bytes in the <paramref name="optionOutValue" /> parameter.
ioControlCode
A <see cref="T:System.Net.Sockets.IOControlCode" /> value that specifies the control code of the operation to perform.
optionInValue
An array of type <see cref="T:System.Byte" /> that contains the input data required by the operation.
optionOutValue
An array of type <see cref="T:System.Byte" /> that contains the output data returned by the operation.
public
void
Listen​()
Places a <see cref="T:System.Net.Sockets.Socket" /> in a listening state.
public
void
Listen​(int backlog)
Places a <see cref="T:System.Net.Sockets.Socket" /> in a listening state.
backlog
The maximum length of the pending connections queue.
public
bool
Poll​(int microSeconds,
SelectMode mode)
Determines the status of the <see cref="T:System.Net.Sockets.Socket" /> .
Returns The status of the <see cref="T:System.Net.Sockets.Socket" /> based on the polling mode value passed in the <paramref name="mode" /> parameter.
<ul>
<li>For <see cref="F:System.Net.Sockets.SelectMode.SelectRead" />, it returns <see langword="true" /> if <see cref="M:System.Net.Sockets.Socket.Listen" /> has been called and a connection is pending, if data is available for reading, or if the connection has been closed, reset, or terminated.</li>
<li>For <see cref="F:System.Net.Sockets.SelectMode.SelectWrite" />, it returns <see langword="true" /> if processing a <see cref="Overload:System.Net.Sockets.Socket.Connect" /> and the connection has succeeded or if data can be sent.</li>
<li>For <see cref="F:System.Net.Sockets.SelectMode.SelectError" />, it returns <see langword="true" /> if processing a <see cref="Overload:System.Net.Sockets.Socket.Connect" /> that does not block and the connection has failed, or if <see cref="F:System.Net.Sockets.SocketOptionName.OutOfBandInline" /> is not set and out-of-band data is available.</li>
<li>Otherwise, it returns <see langword="false" />.</li>
</ul>
microSeconds
The time to wait for a response, in microseconds.
mode
One of the <see cref="T:System.Net.Sockets.SelectMode" /> values.
public
bool
Poll​(TimeSpan timeout,
SelectMode mode)
Determines the status of the <see cref="T:System.Net.Sockets.Socket" /> .
Returns The status of the <see cref="T:System.Net.Sockets.Socket" /> based on the polling mode value passed in the <paramref name="mode" /> parameter. Returns <see langword="true" /> if any of the following conditions occur before the <paramref name="timeout" /> expires, otherwise, <see langword="false" /> .
<ul>
<li>For <see cref="F:System.Net.Sockets.SelectMode.SelectRead" />, it returns <see langword="true" /> if <see cref="M:System.Net.Sockets.Socket.Listen" /> has been called and a connection is pending, if data is available for reading, or if the connection has been closed, reset, or terminated.</li>
<li>For <see cref="F:System.Net.Sockets.SelectMode.SelectWrite" />, it returns <see langword="true" /> if processing a <see cref="Overload:System.Net.Sockets.Socket.Connect" /> and the connection has succeeded or if data can be sent.</li>
<li>For <see cref="F:System.Net.Sockets.SelectMode.SelectError" />, it returns <see langword="true" /> if processing a <see cref="Overload:System.Net.Sockets.Socket.Connect" /> that does not block and the connection has failed, or if <see cref="F:System.Net.Sockets.SocketOptionName.OutOfBandInline" /> is not set and out-of-band data is available.</li>
<li>Otherwise, it returns <see langword="false" />.</li>
</ul>
timeout
The time to wait for a response.
mode
One of the <see cref="T:System.Net.Sockets.SelectMode" /> values.
public
int
Receive​(byte[] buffer)
Receives data from a bound <see cref="T:System.Net.Sockets.Socket" /> into a receive buffer.
Returns The total number of bytes received. The method returns zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown.
buffer
An array of type <see cref="T:System.Byte" /> that is the storage location for the received data.
public
int
Receive​(byte[] buffer,
int offset,
int size,
SocketFlags socketFlags)
Receives the specified number of bytes from a bound <see cref="T:System.Net.Sockets.Socket" /> into the specified offset position of the receive buffer, using the specified <see cref="T:System.Net.Sockets.SocketFlags" /> .
Returns The total number of bytes received. The method returns zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown.
buffer
An array of type <see cref="T:System.Byte" /> that is the storage location for received data.
offset
The location in <paramref name="buffer" /> to store the received data.
size
The number of bytes to receive.
socketFlags
A bitwise combination of the <see cref="T:System.Net.Sockets.SocketFlags" /> values.
public
int
Receive​(byte[] buffer,
int offset,
int size,
SocketFlags socketFlags,
SocketError& errorCode)
public
int
Receive​(byte[] buffer,
int size,
SocketFlags socketFlags)
Receives the specified number of bytes of data from a bound <see cref="T:System.Net.Sockets.Socket" /> into a receive buffer, using the specified <see cref="T:System.Net.Sockets.SocketFlags" /> .
Returns The total number of bytes received. The method returns zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown.
buffer
An array of type <see cref="T:System.Byte" /> that is the storage location for the received data.
size
The number of bytes to receive.
socketFlags
A bitwise combination of the <see cref="T:System.Net.Sockets.SocketFlags" /> values.
public
int
Receive​(byte[] buffer,
SocketFlags socketFlags)
Receives data from a bound <see cref="T:System.Net.Sockets.Socket" /> into a receive buffer, using the specified <see cref="T:System.Net.Sockets.SocketFlags" /> .
Returns The total number of bytes received. The method returns zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown.
buffer
An array of type <see cref="T:System.Byte" /> that is the storage location for the received data.
socketFlags
A bitwise combination of the <see cref="T:System.Net.Sockets.SocketFlags" /> values.
public
int
Receive​(Collections.​Generic.​IList<​ArraySegment<​byte>> buffers)
Receives data from a bound <see cref="T:System.Net.Sockets.Socket" /> into the list of receive buffers.
Returns The total number of bytes received. The method returns zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown.
buffers
A list of <see cref="T:System.ArraySegment`1" /> s of type <see cref="T:System.Byte" /> that contains the received data.
public
int
Receive​(Collections.​Generic.​IList<​ArraySegment<​byte>> buffers,
SocketFlags socketFlags)
Receives data from a bound <see cref="T:System.Net.Sockets.Socket" /> into the list of receive buffers, using the specified <see cref="T:System.Net.Sockets.SocketFlags" /> .
Returns The total number of bytes received. The method returns zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown.
buffers
A list of <see cref="T:System.ArraySegment`1" /> s of type <see cref="T:System.Byte" /> that contains the received data.
socketFlags
A bitwise combination of the <see cref="T:System.Net.Sockets.SocketFlags" /> values.
public
int
Receive​(Collections.​Generic.​IList<​ArraySegment<​byte>> buffers,
SocketFlags socketFlags,
SocketError& errorCode)
public
int
Receive​(Span<​byte> buffer)
Receives data from a bound <see cref="T:System.Net.Sockets.Socket" /> into a receive buffer.
Returns The total number of bytes received. The method returns zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown.
buffer
A span of bytes that is the storage location for the received data.
public
int
Receive​(Span<​byte> buffer,
SocketFlags socketFlags)
Receives data from a bound <see cref="T:System.Net.Sockets.Socket" /> into a receive buffer, using the specified <see cref="T:System.Net.Sockets.SocketFlags" /> .
Returns The total number of bytes received. The method returns zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown.
buffer
A span of bytes that is the storage location for the received data.
socketFlags
A bitwise combination of the enumeration values that specifies send and receive behaviors.
public
int
Receive​(Span<​byte> buffer,
SocketFlags socketFlags,
SocketError& errorCode)
public
Threading.​Tasks.​Task<​int>
ReceiveAsync​(ArraySegment<​byte> buffer)
Receives data from a connected socket.
Returns A task that represents the asynchronous receive operation. The value of its <see cref="P:System.Threading.Tasks.Task`1.Result" /> property contains the total number of bytes read into <paramref name="buffer" /> between zero (0) and the number of bytes requested. The result value is zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown. If zero bytes are requested, reeceive operations may complete immediately or may not complete until at least one byte is available (but without consuming any data).
buffer
The buffer for the received data.
public
Threading.​Tasks.​Task<​int>
ReceiveAsync​(ArraySegment<​byte> buffer,
SocketFlags socketFlags)
Receives data from a connected socket.
Returns A task that represents the asynchronous receive operation. The value of its <see cref="P:System.Threading.Tasks.Task`1.Result" /> property contains the total number of bytes read into <paramref name="buffer" /> between zero (0) and the number of bytes requested. The result value is zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown. If zero bytes are requested, reeceive operations may complete immediately or may not complete until at least one byte is available (but without consuming any data).
buffer
The buffer for the received data.
socketFlags
A bitwise combination of SocketFlags values that will be used when receiving the data.
public
Threading.​Tasks.​Task<​int>
ReceiveAsync​(Collections.​Generic.​IList<​ArraySegment<​byte>> buffers)
Receives data from a connected socket.
Returns A task that represents the asynchronous receive operation. The value of its <see cref="P:System.Threading.Tasks.Task`1.Result" /> property contains the total number of bytes read into the buffers between zero (0) and the number of bytes requested. The result value is zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown. If zero bytes are requested, reeceive operations may complete immediately or may not complete until at least one byte is available (but without consuming any data).
buffers
A list of buffers for the received data.
public
Threading.​Tasks.​Task<​int>
ReceiveAsync​(Collections.​Generic.​IList<​ArraySegment<​byte>> buffers,
SocketFlags socketFlags)
Receives data from a connected socket.
Returns A task that represents the asynchronous receive operation. The value of its <see cref="P:System.Threading.Tasks.Task`1.Result" /> property contains the total number of bytes read into <paramref name="buffer" /> between zero (0) and the number of bytes requested. The result value is zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown. If zero bytes are requested, reeceive operations may complete immediately or may not complete until at least one byte is available (but without consuming any data).
buffers
A list of buffers for the received data.
socketFlags
A bitwise combination of SocketFlags values that will be used when receiving the data.
public
Threading.​Tasks.​ValueTask<​int>
ReceiveAsync​(Memory<​byte> buffer,
SocketFlags socketFlags,
Threading.​CancellationToken cancellationToken = null)
Receives data from a connected socket.
Returns A <see cref="T:System.Threading.Tasks.ValueTask`1" /> that represents the asynchronous receive operation. The value of its <see cref="P:System.Threading.Tasks.ValueTask`1.Result" /> property contains the total number of bytes read into <paramref name="buffer" /> between zero (0) and the number of bytes requested. The result value is zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown. If zero bytes are requested, receive operations may complete immediately or may not complete until at least one byte is available (but without consuming any data).
buffer
The buffer for the received data.
socketFlags
A bitwise combination of SocketFlags values that will be used when receiving the data.
cancellationToken
A cancellation token that can be used to cancel the asynchronous operation.
public
Threading.​Tasks.​ValueTask<​int>
ReceiveAsync​(Memory<​byte> buffer,
Threading.​CancellationToken cancellationToken = null)
Receives data from a connected socket.
Returns A <see cref="T:System.Threading.Tasks.ValueTask`1" /> that represents the asynchronous receive operation. The value of its <see cref="P:System.Threading.Tasks.ValueTask`1.Result" /> property contains the total number of bytes read into <paramref name="buffer" /> between zero (0) and the number of bytes requested. The result value is zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown. If zero bytes are requested, receive operations may complete immediately or may not complete until at least one byte is available (but without consuming any data).
buffer
The buffer for the received data.
cancellationToken
A cancellation token that can be used to cancel the asynchronous operation.
public
bool
ReceiveAsync​(SocketAsyncEventArgs e)
Begins an asynchronous request to receive data from a connected <see cref="T:System.Net.Sockets.Socket" /> object.
Returns <see langword="true" /> if the I/O operation is pending. The <see cref="E:System.Net.Sockets.SocketAsyncEventArgs.Completed" /> event on the <paramref name="e" /> parameter will be raised upon completion of the operation.
<see langword="false" /> if the I/O operation completed synchronously. In this case, The <see cref="E:System.Net.Sockets.SocketAsyncEventArgs.Completed" /> event on the <paramref name="e" /> parameter will not be raised and the <paramref name="e" /> object passed as a parameter may be examined immediately after the method call returns to retrieve the result of the operation.
e
The <see cref="T:System.Net.Sockets.SocketAsyncEventArgs" /> object to use for this asynchronous socket operation.
public
int
ReceiveFrom​(byte[] buffer,
int offset,
int size,
SocketFlags socketFlags,
EndPoint& remoteEP)
public
int
ReceiveFrom​(byte[] buffer,
int size,
SocketFlags socketFlags,
EndPoint& remoteEP)
public
int
ReceiveFrom​(Span<​byte> buffer,
SocketFlags socketFlags,
EndPoint& remoteEP)
public
int
ReceiveFrom​(Span<​byte> buffer,
SocketFlags socketFlags,
SocketAddress receivedAddress)
Receives a datagram into the data buffer, using the specified <see cref="T:System.Net.Sockets.SocketFlags" /> , and stores the endpoint.
Returns The number of bytes received.
buffer
A span of bytes that is the storage location for received data.
socketFlags
A bitwise combination of the <see cref="T:System.Net.Sockets.SocketFlags" /> values.
receivedAddress
A <see cref="T:System.Net.SocketAddress" /> instance that gets updated with the value of the remote peer when this method returns.
public
Threading.​Tasks.​Task<​SocketReceiveFromResult>
ReceiveFromAsync​(ArraySegment<​byte> buffer,
EndPoint remoteEndPoint)
Receives data and returns the endpoint of the sending host.
Returns An asynchronous task that completes with a <see cref="T:System.Net.Sockets.SocketReceiveFromResult" /> containing the number of bytes received and the endpoint of the sending host.
buffer
The buffer for the received data.
remoteEndPoint
An endpoint of the same type as the endpoint of the remote host.
public
Threading.​Tasks.​Task<​SocketReceiveFromResult>
ReceiveFromAsync​(ArraySegment<​byte> buffer,
SocketFlags socketFlags,
EndPoint remoteEndPoint)
Receives data and returns the endpoint of the sending host.
Returns An asynchronous task that completes with a <see cref="T:System.Net.Sockets.SocketReceiveFromResult" /> containing the number of bytes received and the endpoint of the sending host.
buffer
The buffer for the received data.
socketFlags
A bitwise combination of SocketFlags values that will be used when receiving the data.
remoteEndPoint
An endpoint of the same type as the endpoint of the remote host.
public
Threading.​Tasks.​ValueTask<​SocketReceiveFromResult>
ReceiveFromAsync​(Memory<​byte> buffer,
EndPoint remoteEndPoint,
Threading.​CancellationToken cancellationToken = null)
Receives data and returns the endpoint of the sending host.
Returns An asynchronous task that completes with a <see cref="T:System.Net.Sockets.SocketReceiveFromResult" /> containing the number of bytes received and the endpoint of the sending host.
buffer
The buffer for the received data.
remoteEndPoint
An endpoint of the same type as the endpoint of the remote host.
cancellationToken
A cancellation token that can be used to signal the asynchronous operation should be canceled.
public
Threading.​Tasks.​ValueTask<​SocketReceiveFromResult>
ReceiveFromAsync​(Memory<​byte> buffer,
SocketFlags socketFlags,
EndPoint remoteEndPoint,
Threading.​CancellationToken cancellationToken = null)
Receives data and returns the endpoint of the sending host.
Returns An asynchronous task that completes with a <see cref="T:System.Net.Sockets.SocketReceiveFromResult" /> containing the number of bytes received and the endpoint of the sending host.
buffer
The buffer for the received data.
socketFlags
A bitwise combination of SocketFlags values that will be used when receiving the data.
remoteEndPoint
An endpoint of the same type as the endpoint of the remote host.
cancellationToken
A cancellation token that can be used to signal the asynchronous operation should be canceled.
public
Threading.​Tasks.​ValueTask<​int>
ReceiveFromAsync​(Memory<​byte> buffer,
SocketFlags socketFlags,
SocketAddress receivedAddress,
Threading.​CancellationToken cancellationToken = null)
Receives a datagram into the data buffer, using the specified <see cref="T:System.Net.Sockets.SocketFlags" /> , and stores the endpoint.
Returns An asynchronous task that completes with a <see cref="T:System.Net.Sockets.SocketReceiveFromResult" /> containing the number of bytes received and the endpoint of the sending host.
buffer
The buffer for the received data.
socketFlags
A bitwise combination of the <see cref="T:System.Net.Sockets.SocketFlags" /> values that will be used when receiving the data.
receivedAddress
A <see cref="T:System.Net.SocketAddress" /> instance that gets updated with the value of the remote peer when this method returns.
cancellationToken
A cancellation token that can be used to signal the asynchronous operation should be canceled.
public
bool
ReceiveFromAsync​(SocketAsyncEventArgs e)
Begins to asynchronously receive data from a specified network device.
Returns <see langword="true" /> if the I/O operation is pending. The <see cref="E:System.Net.Sockets.SocketAsyncEventArgs.Completed" /> event on the <paramref name="e" /> parameter will be raised upon completion of the operation.
<see langword="false" /> if the I/O operation completed synchronously. In this case, The <see cref="E:System.Net.Sockets.SocketAsyncEventArgs.Completed" /> event on the <paramref name="e" /> parameter will not be raised and the <paramref name="e" /> object passed as a parameter may be examined immediately after the method call returns to retrieve the result of the operation.
e
The <see cref="T:System.Net.Sockets.SocketAsyncEventArgs" /> object to use for this asynchronous socket operation.
public
int
ReceiveMessageFrom​(byte[] buffer,
int offset,
int size,
SocketFlags& socketFlags,
EndPoint& remoteEP,
IPPacketInformation& ipPacketInformation)
public
int
ReceiveMessageFrom​(Span<​byte> buffer,
SocketFlags& socketFlags,
EndPoint& remoteEP,
IPPacketInformation& ipPacketInformation)
public
Threading.​Tasks.​Task<​SocketReceiveMessageFromResult>
ReceiveMessageFromAsync​(ArraySegment<​byte> buffer,
EndPoint remoteEndPoint)
Receives data and returns additional information about the sender of the message.
Returns An asynchronous task that completes with a <see cref="T:System.Net.Sockets.SocketReceiveMessageFromResult" /> containing the number of bytes received and additional information about the sending host.
buffer
The buffer for the received data.
remoteEndPoint
An endpoint of the same type as the endpoint of the remote host.
public
Threading.​Tasks.​Task<​SocketReceiveMessageFromResult>
ReceiveMessageFromAsync​(ArraySegment<​byte> buffer,
SocketFlags socketFlags,
EndPoint remoteEndPoint)
Receives data and returns additional information about the sender of the message.
Returns An asynchronous task that completes with a <see cref="T:System.Net.Sockets.SocketReceiveMessageFromResult" /> containing the number of bytes received and additional information about the sending host.
buffer
The buffer for the received data.
socketFlags
A bitwise combination of SocketFlags values that will be used when receiving the data.
remoteEndPoint
An endpoint of the same type as the endpoint of the remote host.
public
Threading.​Tasks.​ValueTask<​SocketReceiveMessageFromResult>
ReceiveMessageFromAsync​(Memory<​byte> buffer,
EndPoint remoteEndPoint,
Threading.​CancellationToken cancellationToken = null)
Receives data and returns additional information about the sender of the message.
Returns An asynchronous task that completes with a <see cref="T:System.Net.Sockets.SocketReceiveMessageFromResult" /> containing the number of bytes received and additional information about the sending host.
buffer
The buffer for the received data.
remoteEndPoint
An endpoint of the same type as the endpoint of the remote host.
cancellationToken
A cancellation token that can be used to signal the asynchronous operation should be canceled.
public
Threading.​Tasks.​ValueTask<​SocketReceiveMessageFromResult>
ReceiveMessageFromAsync​(Memory<​byte> buffer,
SocketFlags socketFlags,
EndPoint remoteEndPoint,
Threading.​CancellationToken cancellationToken = null)
Receives data and returns additional information about the sender of the message.
Returns An asynchronous task that completes with a <see cref="T:System.Net.Sockets.SocketReceiveMessageFromResult" /> containing the number of bytes received and additional information about the sending host.
buffer
The buffer for the received data.
socketFlags
A bitwise combination of SocketFlags values that will be used when receiving the data.
remoteEndPoint
An endpoint of the same type as the endpoint of the remote host.
cancellationToken
A cancellation token that can be used to signal the asynchronous operation should be canceled.
public
bool
ReceiveMessageFromAsync​(SocketAsyncEventArgs e)
Begins to asynchronously receive the specified number of bytes of data into the specified location in the data buffer, using the specified <see cref="P:System.Net.Sockets.SocketAsyncEventArgs.SocketFlags" /> , and stores the endpoint and packet information.
Returns <see langword="true" /> if the I/O operation is pending. The <see cref="E:System.Net.Sockets.SocketAsyncEventArgs.Completed" /> event on the <paramref name="e" /> parameter will be raised upon completion of the operation.
<see langword="false" /> if the I/O operation completed synchronously. In this case, The <see cref="E:System.Net.Sockets.SocketAsyncEventArgs.Completed" /> event on the <paramref name="e" /> parameter will not be raised and the <paramref name="e" /> object passed as a parameter may be examined immediately after the method call returns to retrieve the result of the operation.
e
The <see cref="T:System.Net.Sockets.SocketAsyncEventArgs" /> object to use for this asynchronous socket operation.
public static
void
Select​(Collections.​IList checkRead,
Collections.​IList checkWrite,
Collections.​IList checkError,
int microSeconds)
Determines the status of one or more sockets.
checkRead
An <see cref="T:System.Collections.IList" /> of <see cref="T:System.Net.Sockets.Socket" /> instances to check for readability.
checkWrite
An <see cref="T:System.Collections.IList" /> of <see cref="T:System.Net.Sockets.Socket" /> instances to check for writability.
checkError
An <see cref="T:System.Collections.IList" /> of <see cref="T:System.Net.Sockets.Socket" /> instances to check for errors.
microSeconds
The time-out value, in microseconds. A -1 value indicates an infinite time-out.
public static
void
Select​(Collections.​IList checkRead,
Collections.​IList checkWrite,
Collections.​IList checkError,
TimeSpan timeout)
Determines the status of one or more sockets.
checkRead
An <see cref="T:System.Collections.IList" /> of <see cref="T:System.Net.Sockets.Socket" /> instances to check for readability.
checkWrite
An <see cref="T:System.Collections.IList" /> of <see cref="T:System.Net.Sockets.Socket" /> instances to check for writability.
checkError
An <see cref="T:System.Collections.IList" /> of <see cref="T:System.Net.Sockets.Socket" /> instances to check for errors.
timeout
The timeout value. A value equal to -1 microseconds indicates an infinite timeout.
public
int
Send​(byte[] buffer)
Sends data to a connected <see cref="T:System.Net.Sockets.Socket" /> .
Returns The number of bytes sent to the <see cref="T:System.Net.Sockets.Socket" /> .
buffer
An array of type <see cref="T:System.Byte" /> that contains the data to be sent.
public
int
Send​(byte[] buffer,
int offset,
int size,
SocketFlags socketFlags)
Sends the specified number of bytes of data to a connected <see cref="T:System.Net.Sockets.Socket" /> , starting at the specified offset, and using the specified <see cref="T:System.Net.Sockets.SocketFlags" /> .
Returns The number of bytes sent to the <see cref="T:System.Net.Sockets.Socket" /> .
buffer
An array of type <see cref="T:System.Byte" /> that contains the data to be sent.
offset
The position in the data buffer at which to begin sending data.
size
The number of bytes to send.
socketFlags
A bitwise combination of the <see cref="T:System.Net.Sockets.SocketFlags" /> values.
public
int
Send​(byte[] buffer,
int offset,
int size,
SocketFlags socketFlags,
SocketError& errorCode)
public
int
Send​(byte[] buffer,
int size,
SocketFlags socketFlags)
Sends the specified number of bytes of data to a connected <see cref="T:System.Net.Sockets.Socket" /> , using the specified <see cref="T:System.Net.Sockets.SocketFlags" /> .
Returns The number of bytes sent to the <see cref="T:System.Net.Sockets.Socket" /> .
buffer
An array of type <see cref="T:System.Byte" /> that contains the data to be sent.
size
The number of bytes to send.
socketFlags
A bitwise combination of the <see cref="T:System.Net.Sockets.SocketFlags" /> values.
public
int
Send​(byte[] buffer,
SocketFlags socketFlags)
Sends data to a connected <see cref="T:System.Net.Sockets.Socket" /> using the specified <see cref="T:System.Net.Sockets.SocketFlags" /> .
Returns The number of bytes sent to the <see cref="T:System.Net.Sockets.Socket" /> .
buffer
An array of type <see cref="T:System.Byte" /> that contains the data to be sent.
socketFlags
A bitwise combination of the <see cref="T:System.Net.Sockets.SocketFlags" /> values.
public
int
Send​(Collections.​Generic.​IList<​ArraySegment<​byte>> buffers)
Sends the set of buffers in the list to a connected <see cref="T:System.Net.Sockets.Socket" /> .
Returns The number of bytes sent to the <see cref="T:System.Net.Sockets.Socket" /> .
buffers
A list of <see cref="T:System.ArraySegment`1" /> s of type <see cref="T:System.Byte" /> that contains the data to be sent.
public
int
Send​(Collections.​Generic.​IList<​ArraySegment<​byte>> buffers,
SocketFlags socketFlags)
Sends the set of buffers in the list to a connected <see cref="T:System.Net.Sockets.Socket" /> , using the specified <see cref="T:System.Net.Sockets.SocketFlags" /> .
Returns The number of bytes sent to the <see cref="T:System.Net.Sockets.Socket" /> .
buffers
A list of <see cref="T:System.ArraySegment`1" /> s of type <see cref="T:System.Byte" /> that contains the data to be sent.
socketFlags
A bitwise combination of the <see cref="T:System.Net.Sockets.SocketFlags" /> values.
public
int
Send​(Collections.​Generic.​IList<​ArraySegment<​byte>> buffers,
SocketFlags socketFlags,
SocketError& errorCode)
public
int
Send​(ReadOnlySpan<​byte> buffer)
Sends data to a connected <see cref="T:System.Net.Sockets.Socket" /> .
Returns The number of bytes sent to the <see cref="T:System.Net.Sockets.Socket" /> .
buffer
A span of bytes that contains the data to be sent.
public
int
Send​(ReadOnlySpan<​byte> buffer,
SocketFlags socketFlags)
Sends data to a connected <see cref="T:System.Net.Sockets.Socket" /> using the specified <see cref="T:System.Net.Sockets.SocketFlags" /> .
Returns The number of bytes sent to the <see cref="T:System.Net.Sockets.Socket" /> .
buffer
A span of bytes that contains the data to be sent.
socketFlags
A bitwise combination of the enumeration values that specifies send and receive behaviors.
public
int
Send​(ReadOnlySpan<​byte> buffer,
SocketFlags socketFlags,
SocketError& errorCode)
public
Threading.​Tasks.​Task<​int>
SendAsync​(ArraySegment<​byte> buffer)
Sends data on a connected socket.
Returns An asynchronous task that completes with the number of bytes sent.
buffer
The buffer for the data to send.
public
Threading.​Tasks.​Task<​int>
SendAsync​(ArraySegment<​byte> buffer,
SocketFlags socketFlags)
Sends data on a connected socket.
Returns An asynchronous task that completes with the number of bytes sent.
buffer
The buffer for the data to send.
socketFlags
A bitwise combination of SocketFlags values that will be used when sending the data.
public
Threading.​Tasks.​Task<​int>
SendAsync​(Collections.​Generic.​IList<​ArraySegment<​byte>> buffers)
Sends data on a connected socket.
Returns An asynchronous task that completes with the number of bytes sent.
buffers
A list of buffers for the data to send.
public
Threading.​Tasks.​Task<​int>
SendAsync​(Collections.​Generic.​IList<​ArraySegment<​byte>> buffers,
SocketFlags socketFlags)
Sends data on a connected socket.
Returns An asynchronous task that completes with the number of bytes sent.
buffers
A list of buffers for the data to send.
socketFlags
A bitwise combination of SocketFlags values that will be used when sending the data.
public
bool
SendAsync​(SocketAsyncEventArgs e)
Sends data asynchronously to a connected <see cref="T:System.Net.Sockets.Socket" /> object.
Returns <see langword="true" /> if the I/O operation is pending. The <see cref="E:System.Net.Sockets.SocketAsyncEventArgs.Completed" /> event on the <paramref name="e" /> parameter will be raised upon completion of the operation.
<see langword="false" /> if the I/O operation completed synchronously. In this case, The <see cref="E:System.Net.Sockets.SocketAsyncEventArgs.Completed" /> event on the <paramref name="e" /> parameter will not be raised and the <paramref name="e" /> object passed as a parameter may be examined immediately after the method call returns to retrieve the result of the operation.
e
The <see cref="T:System.Net.Sockets.SocketAsyncEventArgs" /> object to use for this asynchronous socket operation.
public
Threading.​Tasks.​ValueTask<​int>
SendAsync​(ReadOnlyMemory<​byte> buffer,
SocketFlags socketFlags,
Threading.​CancellationToken cancellationToken = null)
Sends data on a connected socket.
Returns An asynchronous task that completes with the number of bytes sent.
buffer
The buffer for the data to send.
socketFlags
A bitwise combination of SocketFlags values that will be used when sending the data.
cancellationToken
A cancellation token that can be used to cancel the asynchronous operation.
public
Threading.​Tasks.​ValueTask<​int>
SendAsync​(ReadOnlyMemory<​byte> buffer,
Threading.​CancellationToken cancellationToken = null)
Sends data on a connected socket.
Returns An asynchronous task that completes with the number of bytes sent.
buffer
The buffer for the data to send.
cancellationToken
A cancellation token that can be used to cancel the asynchronous operation.
public
void
SendFile​(string fileName)
Sends the file <paramref name="fileName" /> to a connected <see cref="T:System.Net.Sockets.Socket" /> object with the <see cref="F:System.Net.Sockets.TransmitFileOptions.UseDefaultWorkerThread" /> transmit flag.
fileName
A <see cref="T:System.String" /> that contains the path and name of the file to be sent. This parameter can be <see langword="null" /> .
public
void
SendFile​(string fileName,
byte[] preBuffer,
byte[] postBuffer,
TransmitFileOptions flags)
Sends the file <paramref name="fileName" /> and buffers of data to a connected <see cref="T:System.Net.Sockets.Socket" /> object using the specified <see cref="T:System.Net.Sockets.TransmitFileOptions" /> value.
fileName
The path and name of the file to be sent. This parameter can be <see langword="null" /> .
preBuffer
The data to be sent before the file is sent. This parameter can be <see langword="null" /> .
postBuffer
The data to be sent after the file is sent. This parameter can be <see langword="null" /> .
flags
A bitwise combination of the enumeration values that specifies how the file is transferred.
public
void
SendFile​(string fileName,
ReadOnlySpan<​byte> preBuffer,
ReadOnlySpan<​byte> postBuffer,
TransmitFileOptions flags)
Sends the file <paramref name="fileName" /> and buffers of data to a connected <see cref="T:System.Net.Sockets.Socket" /> object using the specified <see cref="T:System.Net.Sockets.TransmitFileOptions" /> value.
fileName
A <see cref="T:System.String" /> that contains the path and name of the file to be sent. This parameter can be <see langword="null" /> .
preBuffer
A <see cref="T:System.ReadOnlySpan`1" /> that contains data to be sent before the file is sent. This buffer can be empty.
postBuffer
A <see cref="T:System.ReadOnlySpan`1" /> that contains data to be sent after the file is sent. This buffer can be empty.
flags
One or more of <see cref="T:System.Net.Sockets.TransmitFileOptions" /> values.
SendFileAsync​(string fileName,
ReadOnlyMemory<​byte> preBuffer,
ReadOnlyMemory<​byte> postBuffer,
TransmitFileOptions flags,
Threading.​CancellationToken cancellationToken = null)
Sends the file <paramref name="fileName" /> and buffers of data to a connected <see cref="T:System.Net.Sockets.Socket" /> object using the specified <see cref="T:System.Net.Sockets.TransmitFileOptions" /> value.
Returns A value task that represents the asynchronous send file operation.
fileName
A <see cref="T:System.String" /> that contains the path and name of the file to be sent. This parameter can be <see langword="null" /> .
preBuffer
A <see cref="T:System.Byte" /> array that contains data to be sent before the file is sent. This parameter can be <see langword="null" /> .
postBuffer
A <see cref="T:System.Byte" /> array that contains data to be sent after the file is sent. This parameter can be <see langword="null" /> .
flags
One or more of <see cref="T:System.Net.Sockets.TransmitFileOptions" /> values.
cancellationToken
A cancellation token that can be used to cancel the asynchronous operation.
SendFileAsync​(string fileName,
Threading.​CancellationToken cancellationToken = null)
Sends the file <paramref name="fileName" /> to a connected <see cref="T:System.Net.Sockets.Socket" /> object.
Returns A value task that represents the asynchronous send file operation.
fileName
A <see cref="T:System.String" /> that contains the path and name of the file to be sent. This parameter can be <see langword="null" /> .
cancellationToken
A cancellation token that can be used to cancel the asynchronous operation.
public
bool
SendPacketsAsync​(SocketAsyncEventArgs e)
Sends a collection of files or in memory data buffers asynchronously to a connected <see cref="T:System.Net.Sockets.Socket" /> object.
Returns <see langword="true" /> if the I/O operation is pending. The <see cref="E:System.Net.Sockets.SocketAsyncEventArgs.Completed" /> event on the <paramref name="e" /> parameter will be raised upon completion of the operation.
<see langword="false" /> if the I/O operation completed synchronously. In this case, The <see cref="E:System.Net.Sockets.SocketAsyncEventArgs.Completed" /> event on the <paramref name="e" /> parameter will not be raised and the <paramref name="e" /> object passed as a parameter may be examined immediately after the method call returns to retrieve the result of the operation.
e
The <see cref="T:System.Net.Sockets.SocketAsyncEventArgs" /> object to use for this asynchronous socket operation.
public
int
SendTo​(byte[] buffer,
int offset,
int size,
SocketFlags socketFlags,
EndPoint remoteEP)
Sends the specified number of bytes of data to the specified endpoint, starting at the specified location in the buffer, and using the specified <see cref="T:System.Net.Sockets.SocketFlags" /> .
Returns The number of bytes sent.
buffer
An array of type <see cref="T:System.Byte" /> that contains the data to be sent.
offset
The position in the data buffer at which to begin sending data.
size
The number of bytes to send.
socketFlags
A bitwise combination of the <see cref="T:System.Net.Sockets.SocketFlags" /> values.
remoteEP
The <see cref="T:System.Net.EndPoint" /> that represents the destination location for the data.
public
int
SendTo​(byte[] buffer,
int size,
SocketFlags socketFlags,
EndPoint remoteEP)
Sends the specified number of bytes of data to the specified endpoint using the specified <see cref="T:System.Net.Sockets.SocketFlags" /> .
Returns The number of bytes sent.
buffer
An array of type <see cref="T:System.Byte" /> that contains the data to be sent.
size
The number of bytes to send.
socketFlags
A bitwise combination of the <see cref="T:System.Net.Sockets.SocketFlags" /> values.
remoteEP
The <see cref="T:System.Net.EndPoint" /> that represents the destination location for the data.
public
int
SendTo​(byte[] buffer,
EndPoint remoteEP)
Sends data to the specified endpoint.
Returns The number of bytes sent.
buffer
An array of type <see cref="T:System.Byte" /> that contains the data to be sent.
remoteEP
The <see cref="T:System.Net.EndPoint" /> that represents the destination for the data.
public
int
SendTo​(byte[] buffer,
SocketFlags socketFlags,
EndPoint remoteEP)
Sends data to a specific endpoint using the specified <see cref="T:System.Net.Sockets.SocketFlags" /> .
Returns The number of bytes sent.
buffer
An array of type <see cref="T:System.Byte" /> that contains the data to be sent.
socketFlags
A bitwise combination of the <see cref="T:System.Net.Sockets.SocketFlags" /> values.
remoteEP
The <see cref="T:System.Net.EndPoint" /> that represents the destination location for the data.
public
int
SendTo​(ReadOnlySpan<​byte> buffer,
EndPoint remoteEP)
Sends data to the specified endpoint.
Returns The number of bytes sent.
buffer
A span of bytes that contains the data to be sent.
remoteEP
The <see cref="T:System.Net.EndPoint" /> that represents the destination for the data.
public
int
SendTo​(ReadOnlySpan<​byte> buffer,
SocketFlags socketFlags,
EndPoint remoteEP)
Sends data to a specific endpoint using the specified <see cref="T:System.Net.Sockets.SocketFlags" /> .
Returns The number of bytes sent.
buffer
A span of bytes that contains the data to be sent.
socketFlags
A bitwise combination of the <see cref="T:System.Net.Sockets.SocketFlags" /> values.
remoteEP
The <see cref="T:System.Net.EndPoint" /> that represents the destination for the data.
public
int
SendTo​(ReadOnlySpan<​byte> buffer,
SocketFlags socketFlags,
SocketAddress socketAddress)
Sends data to a specific endpoint using the specified <see cref="T:System.Net.Sockets.SocketFlags" /> .
Returns The number of bytes sent.
buffer
A span of bytes that contains the data to be sent.
socketFlags
A bitwise combination of the <see cref="T:System.Net.Sockets.SocketFlags" /> values that will be used when sending the data.
socketAddress
The <see cref="T:System.Net.SocketAddress" /> that represents the destination for the data.
public
Threading.​Tasks.​Task<​int>
SendToAsync​(ArraySegment<​byte> buffer,
EndPoint remoteEP)
Sends data to the specified remote host.
Returns An asynchronous task that completes with the number of bytes sent.
buffer
The buffer for the data to send.
remoteEP
The remote host to which to send the data.
public
Threading.​Tasks.​Task<​int>
SendToAsync​(ArraySegment<​byte> buffer,
SocketFlags socketFlags,
EndPoint remoteEP)
Sends data to the specified remote host.
Returns An asynchronous task that completes with the number of bytes sent.
buffer
The buffer for the data to send.
socketFlags
A bitwise combination of SocketFlags values that will be used when sending the data.
remoteEP
The remote host to which to send the data.
public
bool
SendToAsync​(SocketAsyncEventArgs e)
Sends data asynchronously to a specific remote host.
Returns <see langword="true" /> if the I/O operation is pending. The <see cref="E:System.Net.Sockets.SocketAsyncEventArgs.Completed" /> event on the <paramref name="e" /> parameter will be raised upon completion of the operation.
<see langword="false" /> if the I/O operation completed synchronously. In this case, The <see cref="E:System.Net.Sockets.SocketAsyncEventArgs.Completed" /> event on the <paramref name="e" /> parameter will not be raised and the <paramref name="e" /> object passed as a parameter may be examined immediately after the method call returns to retrieve the result of the operation.
e
The <see cref="T:System.Net.Sockets.SocketAsyncEventArgs" /> object to use for this asynchronous socket operation.
public
Threading.​Tasks.​ValueTask<​int>
SendToAsync​(ReadOnlyMemory<​byte> buffer,
EndPoint remoteEP,
Threading.​CancellationToken cancellationToken = null)
Sends data to the specified remote host.
Returns An asynchronous task that completes with the number of bytes sent.
buffer
The buffer for the data to send.
remoteEP
The remote host to which to send the data.
cancellationToken
A cancellation token that can be used to cancel the asynchronous operation.
public
Threading.​Tasks.​ValueTask<​int>
SendToAsync​(ReadOnlyMemory<​byte> buffer,
SocketFlags socketFlags,
EndPoint remoteEP,
Threading.​CancellationToken cancellationToken = null)
Sends data to the specified remote host.
Returns An asynchronous task that completes with the number of bytes sent.
buffer
The buffer for the data to send.
socketFlags
A bitwise combination of SocketFlags values that will be used when sending the data.
remoteEP
The remote host to which to send the data.
cancellationToken
A cancellation token that can be used to cancel the asynchronous operation.
public
Threading.​Tasks.​ValueTask<​int>
SendToAsync​(ReadOnlyMemory<​byte> buffer,
SocketFlags socketFlags,
SocketAddress socketAddress,
Threading.​CancellationToken cancellationToken = null)
Sends data to a specific endpoint using the specified <see cref="T:System.Net.Sockets.SocketFlags" /> .
Returns An asynchronous task that completes with the number of bytes sent.
buffer
The buffer for the data to send.
socketFlags
A bitwise combination of <see cref="T:System.Net.Sockets.SocketFlags" /> values that will be used when sending the data.
socketAddress
The <see cref="T:System.Net.SocketAddress" /> that represents the destination for the data.
cancellationToken
A cancellation token that can be used to cancel the asynchronous operation.
public
void
SetIPProtectionLevel​(IPProtectionLevel level)
Sets the IP protection level on a socket.
level
The IP protection level to set on this socket.
public
void
SetRawSocketOption​(int optionLevel,
int optionName,
ReadOnlySpan<​byte> optionValue)
Sets a socket option value using platform-specific level and name identifiers.
optionLevel
The platform-defined option level.
optionName
The platform-defined option name.
optionValue
The value to which the option should be set.
public
void
SetSocketOption​(SocketOptionLevel optionLevel,
SocketOptionName optionName,
bool optionValue)
Sets the specified <see cref="T:System.Net.Sockets.Socket" /> option to the specified <see cref="T:System.Boolean" /> value.
optionLevel
One of the <see cref="T:System.Net.Sockets.SocketOptionLevel" /> values.
optionName
One of the <see cref="T:System.Net.Sockets.SocketOptionName" /> values.
optionValue
The value of the option, represented as a <see cref="T:System.Boolean" /> .
public
void
SetSocketOption​(SocketOptionLevel optionLevel,
SocketOptionName optionName,
byte[] optionValue)
Sets the specified <see cref="T:System.Net.Sockets.Socket" /> option to the specified value, represented as a byte array.
optionLevel
One of the <see cref="T:System.Net.Sockets.SocketOptionLevel" /> values.
optionName
One of the <see cref="T:System.Net.Sockets.SocketOptionName" /> values.
optionValue
An array of type <see cref="T:System.Byte" /> that represents the value of the option.
public
void
SetSocketOption​(SocketOptionLevel optionLevel,
SocketOptionName optionName,
int optionValue)
Sets the specified <see cref="T:System.Net.Sockets.Socket" /> option to the specified integer value.
optionLevel
One of the <see cref="T:System.Net.Sockets.SocketOptionLevel" /> values.
optionName
One of the <see cref="T:System.Net.Sockets.SocketOptionName" /> values.
optionValue
A value of the option.
public
void
SetSocketOption​(SocketOptionLevel optionLevel,
SocketOptionName optionName,
object optionValue)
Sets the specified <see cref="T:System.Net.Sockets.Socket" /> option to the specified value, represented as an object.
optionLevel
One of the <see cref="T:System.Net.Sockets.SocketOptionLevel" /> values.
optionName
One of the <see cref="T:System.Net.Sockets.SocketOptionName" /> values.
optionValue
A <see cref="T:System.Net.Sockets.LingerOption" /> or <see cref="T:System.Net.Sockets.MulticastOption" /> that contains the value of the option.
public
void
Shutdown​(SocketShutdown how)
Disables sends and receives on a <see cref="T:System.Net.Sockets.Socket" /> .
how
One of the <see cref="T:System.Net.Sockets.SocketShutdown" /> values that specifies the operation that will no longer be allowed.
public
bool
Equals​(object obj)
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object