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.

System..::..Object
  System.Net.Sockets..::..Socket

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

public class Socket : IDisposable

The Socket type exposes the following members.

  NameDescription
Public methodSocketInitializes a new instance of the Socket class using the specified address family, socket type and protocol.
Top

  NameDescription
Public propertyAvailableGets the amount of data that has been received from the network and is available to be read.
Public propertyLocalEndPointGets the local endpoint.
Public propertyReceiveTimeoutGets or sets a value that specifies the amount of time after which a synchronous Receive call will time out.
Public propertyRemoteEndPointGets the remote endpoint.
Public propertySendTimeoutGets or sets a value that specifies the amount of time after which a synchronous Send call will time out.
Top

  NameDescription
Public methodAcceptCreates a new Socket for a newly created connection.
Public methodBindAssociates a Socket with a local endpoint.
Public methodCloseCloses the Socket connection and releases all associated resources.
Public methodConnectEstablishes a connection to a remote host.
Protected methodDisposeReleases the unmanaged resources used by the Socket, and optionally disposes of the managed resources.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeFrees resources used by the Socket class. (Overrides Object..::..Finalize()()()().)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetSocketOption(SocketOptionLevel, SocketOptionName)Returns the value of a specified Socket option, represented as an object.
Public methodGetSocketOption(SocketOptionLevel, SocketOptionName, array<Byte>[]()[][])Returns the specified Socket option setting, represented as a byte array.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodListenPlaces a Socket in a listening state.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodPollDetermines the status of the Socket.
Public methodReceive(array<Byte>[]()[][])Receives data from a bound Socket into a receive buffer.
Public methodReceive(array<Byte>[]()[][], SocketFlags)Receives data from a bound Socket into a receive buffer, using the specified SocketFlags.
Public methodReceive(array<Byte>[]()[][], Int32, SocketFlags)Receives the specified number of bytes of data from a bound Socket into a receive buffer, using the specified SocketFlags.
Public methodReceive(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.
Public methodReceiveFrom(array<Byte>[]()[][], EndPoint%)Receives a datagram into the data buffer and stores the endpoint.
Public methodReceiveFrom(array<Byte>[]()[][], SocketFlags, EndPoint%)Receives a datagram into the data buffer, using the specified SocketFlags, and stores the endpoint.
Public methodReceiveFrom(array<Byte>[]()[][], Int32, SocketFlags, EndPoint%)Receives the specified number of bytes into the data buffer, using the specified SocketFlags, and stores the endpoint.
Public methodReceiveFrom(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.
Public methodSend(array<Byte>[]()[][])Sends data to a connected Socket.
Public methodSend(array<Byte>[]()[][], SocketFlags)Sends data to a connected Socket using the specified SocketFlags.
Public methodSend(array<Byte>[]()[][], Int32, SocketFlags)Sends the specified number of bytes of data to a connected Socket, using the specified SocketFlags.
Public methodSend(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.
Public methodSendTo(array<Byte>[]()[][], EndPoint)Sends data to the specified endpoint.
Public methodSendTo(array<Byte>[]()[][], SocketFlags, EndPoint)Sends data to a specific endpoint using the specified SocketFlags.
Public methodSendTo(array<Byte>[]()[][], Int32, SocketFlags, EndPoint)Sends the specified number of bytes of data to the specified endpoint using the specified SocketFlags.
Public methodSendTo(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.
Public methodSetSocketOption(SocketOptionLevel, SocketOptionName, Boolean)Sets the specified Socket option to the specified Boolean value.
Public methodSetSocketOption(SocketOptionLevel, SocketOptionName, array<Byte>[]()[][])Sets the specified Socket option to the specified value, represented as a byte array.
Public methodSetSocketOption(SocketOptionLevel, SocketOptionName, Int32)Sets the specified Socket option to the specified integer value.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Explicit interface implemetationPrivate methodIDisposable..::..DisposeInfrastructure. Releases all resources used by the Socket.
Top

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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show: