Socket.EndAccept Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Asynchronously accepts an incoming connection attempt.
Overloads
EndAccept(IAsyncResult) |
Asynchronously accepts an incoming connection attempt and creates a new Socket to handle remote host communication. |
EndAccept(Byte[], IAsyncResult) |
Asynchronously accepts an incoming connection attempt and creates a new Socket object to handle remote host communication. This method returns a buffer that contains the initial data transferred. |
EndAccept(Byte[], Int32, IAsyncResult) |
Asynchronously accepts an incoming connection attempt and creates a new Socket object to handle remote host communication. This method returns a buffer that contains the initial data and the number of bytes transferred. |
EndAccept(IAsyncResult)
- Source:
- Socket.cs
- Source:
- Socket.cs
- Source:
- Socket.cs
Asynchronously accepts an incoming connection attempt and creates a new Socket to handle remote host communication.
public:
System::Net::Sockets::Socket ^ EndAccept(IAsyncResult ^ asyncResult);
public System.Net.Sockets.Socket EndAccept (IAsyncResult asyncResult);
member this.EndAccept : IAsyncResult -> System.Net.Sockets.Socket
Public Function EndAccept (asyncResult As IAsyncResult) As Socket
Parameters
- asyncResult
- IAsyncResult
An IAsyncResult that stores state information for this asynchronous operation as well as any user defined data.
Returns
A Socket to handle communication with the remote host.
Exceptions
asyncResult
is null
.
asyncResult
was not created by a call to BeginAccept(AsyncCallback, Object).
An error occurred when attempting to access the socket.
-or-
.NET 7+ only: The Socket has been closed.
.NET Framework, .NET Core, and .NET 5-6 only: The Socket has been closed.
EndAccept(IAsyncResult) method was previously called.
Remarks
Important
This is a compatibility API. We don't recommend using the APM (Begin*
and End*
) methods for new development. Instead, use the Task
-based equivalents.
EndAccept completes the operation started by BeginAccept. You need to pass the IAsyncResult created by the matching BeginAccept call.
The EndAccept method blocks until a connection is pending in the incoming connection queue. The EndAccept method accepts the incoming connection and returns a new Socket that can be used to send data to and receive data from the remote host.
Note
If you receive a SocketException, use the SocketException.ErrorCode property to obtain the specific error code.
Note
This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing in .NET Framework.
See also
Applies to
EndAccept(Byte[], IAsyncResult)
- Source:
- Socket.cs
- Source:
- Socket.cs
- Source:
- Socket.cs
Asynchronously accepts an incoming connection attempt and creates a new Socket object to handle remote host communication. This method returns a buffer that contains the initial data transferred.
public:
System::Net::Sockets::Socket ^ EndAccept([Runtime::InteropServices::Out] cli::array <System::Byte> ^ % buffer, IAsyncResult ^ asyncResult);
public System.Net.Sockets.Socket EndAccept (out byte[] buffer, IAsyncResult asyncResult);
member this.EndAccept : Byte[] * IAsyncResult -> System.Net.Sockets.Socket
Public Function EndAccept (ByRef buffer As Byte(), asyncResult As IAsyncResult) As Socket
Parameters
- asyncResult
- IAsyncResult
An IAsyncResult object that stores state information for this asynchronous operation as well as any user defined data.
Returns
A Socket object to handle communication with the remote host.
Exceptions
.NET Framework, .NET Core, and .NET 5-6 only: The Socket has been closed.
asyncResult
is empty.
asyncResult
was not created by a call to BeginAccept(AsyncCallback, Object).
EndAccept(IAsyncResult) method was previously called.
An error occurred when attempting to access the socket.
-or-
.NET 7+ only: The Socket has been closed.
Remarks
Important
This is a compatibility API. We don't recommend using the APM (Begin*
and End*
) methods for new development. Instead, use the Task
-based equivalents.
EndAccept completes the operation started by BeginAccept. You need to pass the IAsyncResult created by the matching BeginAccept call.
The buffer
parameter of this overload contains the data that was received in the call to BeginAccept and the bytesTransferred
parameter contains the number of bytes that were transferred in the call.
The EndAccept method blocks until a connection is pending in the incoming connection queue. The EndAccept method accepts the incoming connection and returns a new Socket that can be used to send data to and receive data from the remote host.
Note
If you receive a SocketException, use the SocketException.ErrorCode property to obtain the specific error code.
Note
This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing in .NET Framework.
Applies to
EndAccept(Byte[], Int32, IAsyncResult)
- Source:
- Socket.cs
- Source:
- Socket.cs
- Source:
- Socket.cs
Asynchronously accepts an incoming connection attempt and creates a new Socket object to handle remote host communication. This method returns a buffer that contains the initial data and the number of bytes transferred.
public:
System::Net::Sockets::Socket ^ EndAccept([Runtime::InteropServices::Out] cli::array <System::Byte> ^ % buffer, [Runtime::InteropServices::Out] int % bytesTransferred, IAsyncResult ^ asyncResult);
public System.Net.Sockets.Socket EndAccept (out byte[] buffer, out int bytesTransferred, IAsyncResult asyncResult);
member this.EndAccept : Byte[] * int * IAsyncResult -> System.Net.Sockets.Socket
Public Function EndAccept (ByRef buffer As Byte(), ByRef bytesTransferred As Integer, asyncResult As IAsyncResult) As Socket
Parameters
- bytesTransferred
- Int32
The number of bytes transferred.
- asyncResult
- IAsyncResult
An IAsyncResult object that stores state information for this asynchronous operation as well as any user defined data.
Returns
A Socket object to handle communication with the remote host.
Exceptions
.NET Framework, .NET Core, and .NET 5-6 only: The Socket has been closed.
asyncResult
is empty.
asyncResult
was not created by a call to BeginAccept(AsyncCallback, Object).
EndAccept(IAsyncResult) method was previously called.
An error occurred when attempting to access the socket.
-or-
.NET 7+ only: The Socket has been closed.
Remarks
Important
This is a compatibility API. We don't recommend using the APM (Begin*
and End*
) methods for new development. Instead, use the Task
-based equivalents.
EndAccept completes the operation started by BeginAccept. You need to pass the IAsyncResult created by the matching BeginAccept call.
The EndAccept method blocks until a connection is pending in the incoming connection queue. The EndAccept method accepts the incoming connection and returns a new Socket that can be used to send data to and receive data from the remote host.
Note
If you receive a SocketException, use the SocketException.ErrorCode property to obtain the specific error code.
Note
This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing in .NET Framework.