gtpc1m3i | Transmission Control Protocol/Internet Protocol |
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
- This API is available only to sockets that use TCP/IP native stack
support.
- This unique TPF API function can be issued instead of the
accept function. When a remote client is connected, the TPF
system creates a new ECB and activates the program specified by the
pgm parameter.
- Starting at equate EBW000, data is passed to the program specified by the
pgm parameter in the following format:
ECB Equates
| Length
| Description
|
EBW000
| 4
| Contains the name of the program specified by the pgm
parameter.
|
EBW004
| 4
| The socket descriptor of the listener socket, which is the value of the
s parameter.
|
EBW008
| 4
| The return code, which is -1 if an error occurred; otherwise,
the return code is the socket descriptor of the socket that was just
accepted.
|
EBW012
| 4
| The address of a SOCKADDR structure that contains the address
of the remote client whose connection is being accepted.
|
EBW016
| 8
| The data passed by the original ECB on the parm
parameter.
|
- If the return code passed to pgm is -1 , you can get the
specific error code by calling sock_errno.
- Value
- Description
- SOCNOTSOCK
- Socket s has been cleaned up.
- SOCACCES
- The socket accept user exit rejected the connection request.
- SOCTIMEDOUT
- The operation timed out.
- The program specified by the pgm parameter is activated in the
same subsystem as the program that issued the activate_on_accept
call.
- If the value of the istream parameter is not 0, the program
specified by the pgm parameter is activated on the I-stream
specified by the istream parameter. If the value of the
istream parameter is 0, the TPF scheduler selects the I-stream on
which to activate the program specified by the pgm
parameter.
- The ECB in which pgm is activated is assigned the current
system activation number, not the activation number of the ECB that issued
activate_on_accept.
- The receive timeout value (the SO_RCVTIMEO setsockopt option)
determines how long the TPF system waits for a remote client to be connected
before the activate_on_accept function times out.
- The activate_on_accept function cannot be issued if an
accept call is pending for the socket. These operations are
mutually exclusive.
- The activate_on_accept function cannot be issued if another
activate_on_accept call is already pending for this socket.
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