Berkeley Software Distribution compatibility
Sockets is a Berkeley Software Distribution (BSD) interface.
The semantics, such as the return codes that an application receives and the arguments available on supported functions, are BSD semantics. Some BSD semantics, however, are not available in the IBM® i implementation, and changes might need to be made to a typical BSD socket application in order for it to run on the system.
The following list summarizes the differences between the IBM i implementation and the BSD implementation.
- /etc/hosts, /etc/services, /etc/networks, and /etc/protocols
- For these files, the IBM i implementation supplies the
following database files.
QUSRSYS file Contents QATOCPN List of networks and the corresponding IP addresses. QATOCPP List of protocols that are used in the Internet. QATOCPS List of services and the specific port and protocol that the service uses. - /etc/resolv.conf
- The IBM i implementation requires that
this information is configured using the TCP/IP properties page in IBM Navigator
for i. To access the TCP/IP properties page, complete the
following steps:
- From IBM Navigator for i, expand .
- Click TCP/IP Configuration Properties.
- Saving and Restoring TCP/IP configuration information
- The Retrieve TCP/IP Information (RTVTCPINF) command gathers key TCP/IP configuration information from the default system locations and places it in the library that is specified for the Library (LIB) parameter. The gathered TCP/IP configuration information can be used by the Update TCP/IP Information (UPDTCPINF) command to reset or restore the TCP/IP configuration on a system.
- bind()
On a BSD system, a client can create an AF_UNIX socket using socket(), connect to a server using connect(), and then bind a name to its socket using bind(). The IBM i implementation does not support this scenario (the bind() fails).
- close()
-
The IBM i implementation supports the linger timer for the close() API, except for AF_INET sockets over Systems Network Architecture (SNA). Some BSD implementations do not support the linger timer for the close() API.
- connect()
On a BSD system, if a connect() is issued against a socket that was previously connected to an address and is using a connectionless transport service, and an invalid address or an invalid address length is used, the socket is no longer connected. The IBM i implementation does not support this scenario (the connect() fails and the socket is still connected).
A connectionless transport socket for which a connect() has been issued can be disconnected by setting the address_length parameter to zero and issuing another connect().
- accept(), getsockname(), getpeername(), recvfrom(), and recvmsg()
When using the AF_UNIX or AF_UNIX_CCSID address family and the socket has not been bound, the default IBM i implementation might return an address length of zero and an unspecified address structure. The IBM i BSD 4.4/ UNIX 98 and other implementations might return a small address structure with only the address family specified.
- ioctl()
- On a BSD system, on a socket of type SOCK_DGRAM, the FIONREAD request returns the length of the data plus the length of the address. On the IBM i implementation, FIONREAD only returns the length of data.
- Not all requests available on most BSD implementations of ioctl() are available on the IBM i implementation of ioctl().
- listen()
On a BSD system, issuing a listen() with the backlog parameter set to a value that is less than zero does not result in an error. In addition, the BSD implementation, in some cases, does not use the backlog parameter, or uses an algorithm to come up with a final result for the backlog value. The IBM i implementation returns an error if the backlog value is less than zero. If you set the backlog to a valid value, then the value is used as the backlog. However, setting the backlog to a value larger than {SOMAXCONN}, the backlog defaults to the value set in {SOMAXCONN}.
- Out-of-band (OOB) data
In the IBM i implementation, OOB data is not discarded if SO_OOBINLINE is not set, OOB data has been received, and the user then sets SO_OOBINLINE on. The initial OOB byte is considered normal data.
- protocol parameter of socket()
As a means of providing additional security, no user is allowed to create a SOCK_RAW socket specifying a protocol of IPPROTO_TCP or IPPROTO_UDP.
- res_xlate() and res_close()
These APIs are included in the resolver routines for the IBM i implementation. The res_xlate() API translates Domain Name System (DNS) packets from EBCDIC to ASCII and from ASCII to EBCDIC. The res_close() API is used to close a socket that was used by the res_send() API with the RES_STAYOPEN option set. The res_close() API also resets the _res structure.
- sendmsg() and recvmsg()
-
The IBM i implementation of sendmsg() and recvmsg() allows {MSG_MAXIOVLEN} I/O vectors. The BSD implementation allows {MSG_MAXIOVLEN - 1} I/O vectors.
- Signals
- There are several differences relating to signal support:
- BSD implementations issue a SIGIO signal each time an acknowledgment is received for data sent on an output operation. The IBM i sockets implementation does not generate signals related to outbound data.
- The default action for the SIGPIPE signal is to end the process in BSD implementations. To maintain downward compatibility with previous releases of IBM i, the IBM i implementation uses a default action of ignoring for the SIGPIPE signal.
- SO_REUSEADDR option
-
On BSD systems, a connect() all on a socket of family AF_INET and type SOCK_DGRAM causes the system to change the address to which the socket is bound to the address of the interface that is used to reach the address specified on the connect() API. For example, if you bind a socket of type SOCK_DGRAM to address INADDR_ANY, and then connect it to an address of a.b.c.d, the system changes your socket so it is now bound to the IP address of the interface that was chosen to route packets to address a.b.c.d. In addition, if this IP address that the socket is bound to is a.b.c.e, for example, address a.b.c.e now appears on the getsockname() API instead of INADDR_ANY, and the SO_REUSEADDR option must be used to bind any other sockets to the same port number with an address of a.b.c.e.
In contrast, in this example, the IBM i implementation does not change the local address from INADDR_ANY to a.b.c.e. The getsockname() API continues to return INADDR_ANY after the connection is performed.
- SO_SNDBUF and SO_RCVBUF options
The values set for SO_SNDBUF and SO_RCVBUF on a BSD system provide a greater level of control than on an IBM i implementation. On an IBM i implementation, these values are taken as advisory values.