SD - The Open Source, Multivalue, String, Database

The ACCEPT.SOCKET.CONNECTION() function opens a data socket on a server to handle an incoming connection.


Format: ACCEPT.SOCKET.CONNECTION(srvr.skt, timeout)


Parameters:


srvr.skt is the server socket created by an earlier use of CREATE.SERVER.SOCKET.

timeout is the timeout period in milliseconds. A value of zero implies no timeout.


The ACCEPT.SOCKET.CONNECTION() function waits for an incoming connection on a previously created server socket and returns a new data socket for this connection.


If the action is successful, the function returns a socket variable that can be used to read and write data using the READ.SOCKET() and WRITE.SOCKET() functions. The  STATUS()function will return zero.


If the socket cannot be opened, the STATUS() function will return an error code that can be used to identify the cause of the error. If no connection arrives before the timeout period expires, the error code will be ER$TIMEOUT as defined in the SYSCOM ERR.H include record.


Example:


SRVR.SKT = CREATE.SERVER.SOCKET("", 0)

IF STATUS() THEN STOP 'Cannot initialise server socket'

SKT = ACCEPT.SOCKET.CONNECTION(SRVR.SKT, 0)

IF STATUS() THEN STOP 'Error accepting connection'

DATA = READ.SOCKET(SKT, 100, SKT$BLOCKING, 0)

CLOSE.SOCKET SKT

CLOSE.SOCKET SRVR.SKT


This program fragment creates a server socket, waits for an incoming connection, reads a single data packet from this connection and then closes the sockets.

SD Basic Command - ACCEPT.SOCKET.CONNECTION

OpenQM 2.6.6 documentation for this command is available here.  The OpenQM documentation may provide additional context for this command.  However, some features in SD have been modified so the OpenQM information may not be 100% applicable to SD.