System.Net.Socket.TSocket.Accept

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function Accept(Timeout: Cardinal = INFINITE): TSocket;

C++

TSocket* __fastcall Accept(unsigned Timeout = (unsigned)(0xffffffff));

Properties

Type Visibility Source Unit Parent
function public
System.Net.Socket.pas
System.Net.Socket.hpp
System.Net.Socket TSocket

Description

Blocks the caller of this function until a client connects, and then returns a new instance of Socket.TSocket.

If the specified timeout passes before a client connects, Accept returns nil. Timeout is a value in milliseconds.

You must call Listen to configure your socket to listen to incoming connection before you can call Accept to accept one of those incoming connections.

The caller becomes the owner of the returned instance of Socket.TSocket. The caller is responsible for destroying the returned socket once it is no longer necessary.

Exceptions

A call to Accept can raise any of the following exceptions:

Exception Exception.Message Scenarios

ESocketError

Network socket error: <error message> (<error code>), on API 'accept'

Network socket error: <error message> (<error code>), on API 'select'

Socket not listening

  • Before you accept an incoming connection, you must call Listen to configure your socket to listen for incoming connections.

See Also