WsAccept Procedure

Permits an incoming connection attempt on a socket and returns a socket to the new connection.

Syntax

[ socket1 = ] WsAccept ( socket, lTimeOut )

The WsAccept procedure syntax has the following parts:

 

Name

Type

Description

socket1

ASocket

If no error occurs, this returned value is a handle for the socket on which the actual connection is made.

socket

Val ASocket

A handle identifying a socket that has been placed in a listening state with the WsListen() function. The connection is actually made with the socket that is returned by WsAccept().

lTimeout

Val Long

Max time in milliseconds to wait to acquire the new connection.

Remarks:

A server calls this function. It accepts a client connection.

The TCP server socket uses the WsAccept function to accept the client connection. That completes the name association between client and server.

The WsAccept function creates a new socket. The original socket opened by the server continues to listen and can be used to accept more connections until closed. Server applications must close the listening socket in addition to any sockets created to accept a client connection.

Example

The following example shows how to use the WsAccept function:

! Open a socket of TCP/IP protocol:

lSocket1=WsCreate(aWsTcpIp,0)

! Associate a local host with a socket at a local port:

WsBind(lSocket1,lPort,lHost)

! Set the Socket to listen for an incoming connection from a client:

WsListen(lSocket1)

! Attempts to return a readwrite socket to the remote client in twenty seconds:

lSocket2=WsAccept(lSocket1,20000) 

See Also

WsClose, WsConnect, WsGetAddress, WsListen, WsReceive