ACCEPT Statement

Declares the availability of the server to the local session manager, or establishes a connection to a client that has just requested a connection.

Syntax

ACCEPT accept-string TO session {TIMEOUT minutes} {SETTING error} {RETURNING client-id} [THEN statement(s) | ELSE statement(s)]

Syntax Elements

accept-stringA string with one of the formats described in the section Accept String.

sessionA variable in which to return a 'session handle'; that is, a value that identifies the connection.

minutesAn expression that evaluates to a timeout in minutes. The ELSE clause is executed if a connect request is not received and a session established within this time. If a connect request is not received and the TIMEOUT clause is omitted (or minutes = 0), error is set to 4225 and the ELSE clause is taken.

client-idA variable in which to return a dynamic array containing two attributes that identify the client program; that is:

client-plid^client-system*user-id

where:

client-plid is the PLId of the process running the client program.

client-system is the name of the database running the client program; that is, the name of a Q-type (UNIX) or Remote Database (Windows) entry in the ROUTE-FILEClosed /etc/ROUTE-FILE is a file on a UNIX host containing items that control the routing a particular process will take through a network. Routing control includes destination system names, network addresses, etc. On Windows hosts, this information is held in the Registry. For Reality external components that use the PC Standard Network Interface for Windows (PCSNI), routing information is held in a file called winsni.ini in the Windows folder.  .

user-id is the user-id used to logon the client process. This forms part of the second attribute and is separated from the first part, client-system, by an asterisk (*).

^ represents an attribute mark.

error A variable in which to return an error code number representing any errors detected if the ELSE clause is taken. If the ELSE clause is not taken, the value of error is set to 0. The error codes and corresponding messages are given in File I/O and IPC Error Codes.

statement(s) One or more DataBasic statements, forming a THEN or ELSE clause (or both). At least one statement must be included. The THEN clause is executed if the ACCEPT establishes a session without error; otherwise, the ELSE clause is executed.

Accept String

The accept-string parameter must be a string with one of the following formats:

Operation

DDA Connections

The ACCEPT statement is used either to declare to the Session Manager that the server is available to any client that might subsequently request connection or it might be used as a reply to accept connection to a client that has just requested connection.

Raw TCP/IP Connections

When using the ACCEPT statement to accept raw TCP/IP connections, you must first create a listening socket by issuing an ACCEPT with the listen option. For example:

ACCEPT "*TCP*152.114.24.126;port=1045;listen=1" TO LISTENSESS ELSE STOP

Incoming connections from this host will then be queued. The listen option specifies the size of the queue (note that the operating system may limit on the size of the queue).

Subsequent ACCEPT calls, specifying the same host and port, but without the listen option, can then be used to fetch connection requests from the queue. For example:

ACCEPT "*TCP*152.114.24.126;port=1045" TO CONNSESS ELSE STOP

When your program has finished with a connection or no longer wishes to accept incoming connections on the specified address, it should issue a disconnect:

DISCONNECT CONNSESS ELSE STOP

Examples

Programming in DataBasic contains example programs that use the ACCEPT statement.