gtpc1m3iTransmission Control Protocol/Internet Protocol

activate_on_accept -- Activate a Program When the Client Connects

The activate_on_accept function allows the issuing entry control block (ECB) to exit and activate a different ECB in the program specified when a remote client is connected.

Format

#include <socket.h>
int      activate_on_accept(unsigned int s,
                            unsigned char *parm,
                            unsigned char *pgm,
                            unsigned int istream);

s
The socket descriptor.

parm
A pointer to an 8-byte field. The data in this field is saved and passed to a new ECB starting at equate EBW016. This new ECB is created when a remote client is connected.

pgm
A pointer to a 4-byte field that contains the name of the TPF real-time program to be activated when a remote client is connected.

istream
The I-stream number on which to activate the program specified by the pgm parameter. If the value is 0, the TPF scheduler selects the I-stream.

Normal Return

Return code 0 indicates that the function was successful.

Error Return

Return code -1 indicates an error. You can get the specific error code by calling sock_errno. See Appendix C, Socket Error Return Codes for more information about socket errors.

Value
Description

SOCNOTSOCK
The s parameter is not a valid socket descriptor.

SOCINVAL
The listen function was not called for socket s, or the activate_on_accept or accept function is already pending for socket s, or the I-stream value supplied for activate_on_accept was not valid.

SOCINPROGRESS
Socket s is marked nonblocking, and the connection cannot be completed immediately. The SOCINPROGRESS value does not indicate an error condition.

SOCSOCKTNOSUPPORT
Socket s is not a stream socket.

E1052STATE
The socket was closed because the system was in or cycling down to 1052 state.

ESYSTEMERROR
The system closed the socket because pgm is not a valid program name.

Programming Considerations

Examples

After accepting a connection from a new client, an activate_on_accept function is issued so that server_sock can accept the next client request.

#include <types.h>
#include <socket.h>

·
·
·
int newclient_sock; int server_sock; int i_stream; u_char aoaparm[8]; u_char aoapgm[4] = "abcd";
·
·
·
/* No parameters will be passed to the new ECB */ memset(aoaparm,0,sizeof(aoaparm)); rc = activate_on_accept(newclient_sock,aoaparm,aoapgm) i_stream);
·
·
·

Related Information