gtpc1m41Transmission Control Protocol/Internet Protocol

ioctl -- Perform Special Operations on Socket

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:

  1. TCP/IP activate on receipt load balancing can be set on only for applications that run on any I-stream.

  2. TCP/IP activate on receipt load balancing is only available for sockets that use TCP/IP native stack support.

  3. 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

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.