Socket Class
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Implements the Berkeley sockets interface.
Inheritance Hierarchy
System. . :: . .Object
System.Net.Sockets..::..Socket
Namespace: System.Net.Sockets
Assembly: System (in System.dll)
Syntax
'Declaration
Public Class Socket _
Implements IDisposable
public class Socket : IDisposable
public ref class Socket : IDisposable
type Socket =
class
interface IDisposable
end
public class Socket implements IDisposable
The Socket type exposes the following members.
Constructors
Name | Description | |
---|---|---|
Socket | Initializes a new instance of the Socket class using the specified address family, socket type and protocol. |
Top
Properties
Name | Description | |
---|---|---|
Available | Gets the amount of data that has been received from the network and is available to be read. | |
LocalEndPoint | Gets the local endpoint. | |
ReceiveTimeout | Gets or sets a value that specifies the amount of time after which a synchronous Receive call will time out. | |
RemoteEndPoint | Gets the remote endpoint. | |
SendTimeout | Gets or sets a value that specifies the amount of time after which a synchronous Send call will time out. |
Top
Methods
Name | Description | |
---|---|---|
Accept | Creates a new Socket for a newly created connection. | |
Bind | Associates a Socket with a local endpoint. | |
Close | Closes the Socket connection and releases all associated resources. | |
Connect | Establishes a connection to a remote host. | |
Dispose | Releases the unmanaged resources used by the Socket, and optionally disposes of the managed resources. | |
Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
Finalize | Frees resources used by the Socket class. (Overrides Object. . :: . .Finalize() () () ().) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetSocketOption(SocketOptionLevel, SocketOptionName) | Returns the value of a specified Socket option, represented as an object. | |
GetSocketOption(SocketOptionLevel, SocketOptionName, array<Byte> [] () [] []) | Returns the specified Socket option setting, represented as a byte array. | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
Listen | Places a Socket in a listening state. | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
Poll | Determines the status of the Socket. | |
Receive(array<Byte> [] () [] []) | Receives data from a bound Socket into a receive buffer. | |
Receive(array<Byte> [] () [] [], SocketFlags) | Receives data from a bound Socket into a receive buffer, using the specified SocketFlags. | |
Receive(array<Byte> [] () [] [], Int32, SocketFlags) | Receives the specified number of bytes of data from a bound Socket into a receive buffer, using the specified SocketFlags. | |
Receive(array<Byte> [] () [] [], Int32, Int32, SocketFlags) | Receives the specified number of bytes from a bound Socket into the specified offset position of the receive buffer, using the specified SocketFlags. | |
ReceiveFrom(array<Byte> [] () [] [], EndPoint%) | Receives a datagram into the data buffer and stores the endpoint. | |
ReceiveFrom(array<Byte> [] () [] [], SocketFlags, EndPoint%) | Receives a datagram into the data buffer, using the specified SocketFlags, and stores the endpoint. | |
ReceiveFrom(array<Byte> [] () [] [], Int32, SocketFlags, EndPoint%) | Receives the specified number of bytes into the data buffer, using the specified SocketFlags, and stores the endpoint. | |
ReceiveFrom(array<Byte> [] () [] [], Int32, Int32, SocketFlags, EndPoint%) | Receives the specified number of bytes of data into the specified location of the data buffer, using the specified SocketFlags, and stores the endpoint. | |
Send(array<Byte> [] () [] []) | Sends data to a connected Socket. | |
Send(array<Byte> [] () [] [], SocketFlags) | Sends data to a connected Socket using the specified SocketFlags. | |
Send(array<Byte> [] () [] [], Int32, SocketFlags) | Sends the specified number of bytes of data to a connected Socket, using the specified SocketFlags. | |
Send(array<Byte> [] () [] [], Int32, Int32, SocketFlags) | Sends the specified number of bytes of data to a connected Socket, starting at the specified offset, and using the specified SocketFlags. | |
SendTo(array<Byte> [] () [] [], EndPoint) | Sends data to the specified endpoint. | |
SendTo(array<Byte> [] () [] [], SocketFlags, EndPoint) | Sends data to a specific endpoint using the specified SocketFlags. | |
SendTo(array<Byte> [] () [] [], Int32, SocketFlags, EndPoint) | Sends the specified number of bytes of data to the specified endpoint using the specified SocketFlags. | |
SendTo(array<Byte> [] () [] [], Int32, Int32, SocketFlags, EndPoint) | Sends the specified number of bytes of data to the specified endpoint, starting at the specified location in the buffer, and using the specified SocketFlags. | |
SetSocketOption(SocketOptionLevel, SocketOptionName, Boolean) | Sets the specified Socket option to the specified Boolean value. | |
SetSocketOption(SocketOptionLevel, SocketOptionName, array<Byte> [] () [] []) | Sets the specified Socket option to the specified value, represented as a byte array. | |
SetSocketOption(SocketOptionLevel, SocketOptionName, Int32) | Sets the specified Socket option to the specified integer value. | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
Explicit Interface Implementations
Name | Description | |
---|---|---|
IDisposable. . :: . .Dispose | Infrastructure. Releases all resources used by the Socket. |
Top
Remarks
The Socket class provides a rich set of methods and properties for network communications. The Socket class allows you to perform both synchronous and asynchronous data transfer using any of the communication protocols listed in the ProtocolType enumeration.
The Socket class allows you to configure your Socket using the SetSocketOption method. Retrieve these settings using the GetSocketOption method.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.