The CREATE.SERVER.SOCKET() function creates a server socket on which a program may wait for incoming connections.
CREATE.SERVER.SOCKET(addr, port, flags)
Socket type, one of:
Protocol, one of:
The addr argument may be
•An IPV4 network IP address. Only incoming connections from other IPV4 addresses will be accepted.
•An IPV6 network IP address Only incoming connections from other IPV6 addresses will be accepted.
•A server name that will be translated to a network address
•A null string. Connections may be made from either IPV4 or IPV6 addresses.
•For Unix domain sockets, the addr argument is the pathname of the socket connection and the port argument is ignored.
When the IPADDR configuration parameter is used to cause QM to listen for incoming telnet, QMClient, QMNet or replication connections on a specific IP address, the SYSTEM(1071) function may be useful as the addr argument so that the same IP address is used by CREATE.SERVER.SOCKET.
Use of IPV6 must be enabled using the IPV6 configuration parameter.
If the action is successful, this function returns the socket variable associated with the new server port and the STATUS() function returns zero.
If unsuccessful, the STATUS() function returns an error code that can be used to determine the cause of failure.
Use of CREATE.SERVER.SOCKET() within a phantom process makes that process consume a licence.
SRVR.SKT = CREATE.SERVER.SOCKET("", 4000, SKT$STREAM + SKT$TCP)
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)
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.