gtpc1m41 | Transmission Control Protocol/Internet Protocol |
The ioctl function performs special operations on socket
descriptor s.
Format
#include <types.h>
#include <socket.h>
#include <ioctl.h>
int ioctl(int s,
int cmd,
char *arg);
- s
- The socket descriptor.
- cmd
- Command to perform. Use one of the following values:
- AOR_BALANCE
- Sets TCP/IP activate on receipt load balancing on or off for a
socket. If load balancing is set on, the ECB is created on the least
busy I-stream when an activate_on_receipt or
activate_on_receipt_with_length function is completed. If
load balancing is set off, the ECB is created on the I-stream of the ECB that
issued the activate_on_receipt or
activate_on_receipt_with_length function request. The
arg parameter is a pointer to an integer. If the integer is
nonzero, load balancing is set on; otherwise, load balancing is set
off.
Notes:
- TCP/IP activate on receipt load balancing can be set on only for
applications that run on any I-stream.
- TCP/IP activate on receipt load balancing is only available for sockets
that use TCP/IP native stack support.
- The AOR_BALANCE parameter is unique to the TPF 4.1 system.
- FIONBIO
- Sets or clears nonblocking input/output for a socket. The
arg parameter is a pointer to an integer. If the integer is
0, nonblocking input/output on the socket is cleared. Otherwise, the
socket is set for nonblocking input/output.
- FIONREAD
- Gets the number of immediately readable bytes for the socket. The
arg parameter is a pointer to an integer. Sets the value of
the integer to the number of immediately readable characters for the
socket.
- SIOCADDRT
- Adds a routing table entry. The arg parameter is a
pointer to a rtentry structure as defined in
ioctl.h. The routing table entry, passed as an
argument, is added to the routing tables. This option is for IBM use
only.
- SIOCATMARK
- Queries whether the current location in the data input is pointing to
out-of-band data. The arg parameter is a pointer to an
integer. Sets the argument to 1 if the socket points to a mark in the
data stream for out-of-band data. Otherwise, sets the argument to
0.
- SIOCDELRT
- Deletes a routing table entry. The arg parameter is a
pointer to a rtentry structure. If it exists, the routine
table entry, passed as an argument, is deleted from the routing tables.
This option is for IBM use only.
- SIOCGIFADDR
- Gets the network interface address. The arg parameter is
a pointer to an ifreq structure, as defined in
ioctl.h. The interface address is returned in the
field in the ifreq structure that has the result.
- SIOCGIFBRDADDR
- Gets the network interface broadcast address. The arg
parameter is a pointer to an ifreq structure as defined in
ioctl.h. The interface broadcast address is returned
in the argument.
- SIOCGIFCONF
- Gets the network interface configuration. The arg
parameter is a pointer to an ifconf structure as defined in
ioctl.h. The interface configuration is returned in
the argument. The length must be at least 32 bytes.
- SIOCGIFDSTADDR
- Gets the network interface destination address. The arg
parameter is a pointer to an ifreq structure as defined in
ioctl.h. The interface destination (point-to-point)
address is returned in the argument.
- SIOCGIFFLAGS
- Gets the network interface flags. The arg parameter is a
pointer to an ifreq structure as defined in
ioctl.h. The interface flags are returned in the
argument.
- SIOCGIFMETRIC
- Gets the network interface routing metric. The arg
parameter is a pointer to an ifreq structure as defined in
ioctl.h. The interface routine metric is returned in
the argument. This option is for IBM use only.
- SIOGIFNETMASK
- Gets the network interface network mask. The arg
parameter is a pointer to an ifreq structure as defined in
ioctl.h. The interface network mask is returned in
the argument.
- SIOCSIFDSTADDR
- Sets the network interface destination address. The arg
parameter is a pointer to an ifreq structure as defined in
ioctl.h. Sets the interface destination
(point-to-point) address to the value passed in the argument. This
option is for IBM use only.
- SIOCSIFFLAGS
- Sets the network interface flags. The arg parameter is a
pointer to an ifreq structure as defined in
ioctl.h. Sets the interface flags to the values
passed in the argument. This option is for IBM use only.
- SIOCSIFMETRIC
- Sets the network interface routing metric. The arg
parameter is a pointer to an ifreq structure as defined in
ioctl.h. Sets the interface routing metric to the
value passed in the argument. This option is for IBM use only.
- TPF_NOSWEEP
- Skips the socket sweeper processing for this socket. The socket
sweeper facility monitors open sockets and closes those that are idle.
An idle socket is one that has had no socket application programming
interfaces (APIs) issued recently by any application. The
arg parameter is a pointer to an integer. If the integer is
any nonzero value, the socket sweeper facility will skip monitoring the socket
descriptor supplied by the s parameter for socket API
activity. If the arg parameter is set to zero, the socket
sweeper monitors the socket descriptor.
- Note:
- The TPF_NOSWEEP parameter is unique to the TPF 4.1 system.
- arg
- Pointer to the data associated with cmd, and its format depends
on the command that is requested.
Normal Return
Return code 0 indicates that the function was successful.
Error Return
A return code equal to -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.
- Note:
- Unless otherwise stated in the description, the following error codes can be
returned for either TCP/IP offload support or TCP/IP native stack
support.
- Value
- Description
- SOCOPNOTSUP
- The operation is not supported on the socket.
- SOCNOTCONN
- The socket is not connected.
- SOCINVAL
- The request is not valid or not supported or the buffer passed was not the
required minimum length.
- SOCFAULT
- Using buf and len would result in an attempt to
access a protected address space. This error code is returned only for
TCP/IP native stack support.
- SOCNOTSOCK
- The s parameter is not a valid socket descriptor.
- SOCNOBUFS
- There is not enough buffer space available to process the message.
This error code is returned only for TCP/IP offload support.
- EIBMIUCVERR
- An error occurred while the function call was sent to the offload
device. This error code is returned only for TCP/IP offload
support.
- E1052STATE
- The socket was closed because the system was in or cycling down to 1052
state.
- EINACT
- All offload devices associated with the socket descriptor have been
disconnected. The socket is closed. This error code is returned
only for TCP/IP offload support.
- EINACTWS
- An offload device associated with the socket descriptor has been
disconnected. The socket is still available. This error code is
returned only for TCP/IP offload support.
- ESYSTEMERROR
- A system error has occurred and closed the socket. This error code
is returned only for TCP/IP offload support.
- OFFLOADTIMEOUT
- The offload device did not respond to the function call in a specified
time period. This error code is returned only for TCP/IP offload
support.
Programming Considerations
- The operating characteristics of sockets can be controlled with the
ioctl function. The operations to be controlled are
determined by the cmd parameter. The arg
parameter is a pointer to data associated with the particular command.
- For sockets using TCP/IP native stack support, the TPF_NOSWEEP parameter
only affects socket sweeper processing based on application idle
timeouts. Sockets that issue this cmd parameter value can
still be swept because of network idle timeouts.
- TPF_NOSWEEP has no effect when the TPF socket sweeper facility is not
active. ZNKEY SOCKSWP displays the current sweep timeout; a
timeout of 0 indicates the sweeper is not active. When the socket
sweeper facility is activated, the latest value for TPF_NOSWEEP determines
whether the socket sweeper monitors the socket descriptor.
- Open sockets are subject to socket sweeper monitoring by default.
Examples
The following example sets server_sock to be in nonblocking
mode.
#include <types.h>
#include <socket.h>
#include <ioctl.h>
·
·
·
int dontblock;
int rc;
int server_sock
·
·
·
/* Place the socket into nonblocking mode */
dontblock = 1;
rc = ioctl(server_sock, FIONBIO, (char *) &dontblock);
Related Information
sock_errno -- Return the Error Code Set by a Socket Call.