IBM Support

Calling Programs and Stored Procedures That Use Sockets from a Host Server Job

Troubleshooting


Problem

Care must be taken with socket descriptors in programs to avoid causing communications errors.

Resolving The Problem

Users might have programs that use sockets to communicate with other systems. These programs can be called from the database host server as a stored procedure or a trigger invoked from an ODBC, OLEDB, ADO.Net, or JDBC client. The programs can also be called from the program call/remote command server by using IBM i Access Client Solutions APIs or IBM Toolbox for Java classes. When a user-written program that makes socket calls is invoked through a host server, the programmer must ensure that they do not make a call on the socket descriptor used by the host server to communicate with the client.

A common programming error is to issue a close on an uninitialized socket descriptor variable. The error often occurs in an error handling routine or initialization function. This function might attempt a close as part of its cleanup without verifying that the socket was successfully opened. This works when the program is called interactively. However, when called through a host server, this will usually close the socket descriptor being used by the host server causing an error.

Common errors include:
  • Communications error on the client.
  • QZDASOINIT jobs might go into a loop with no error being reported in the job log. VLOG 0700 F230 is logged against the job. (Error reporting was improved in V5R3.)
  • QZDASOINIT jobs might report the following errors: CPE3450 - Descriptor not valid, CPIAD08 RC3450 - Host server communications error occurred.
  • QZRCSRVS jobs might report message CPIAD07 f/QZBSCOMM t/QZBSCOMM Host server error occurred with reason code 10. Reallocation of server buffer failed. The error invalid socket descriptor can also be logged.
The reason for the error has to do with the socket descriptor values returned by the operating system socket layer. In the current releases, the operating system starts numbering with 0. Because the host server is the first program to open a socket (and socket descriptors are scoped to the job), the host server uses socket descriptor 0. Most programming languages initialize variables to 0. If the programmer uses an uninitialized socket descriptor variable in a program, the socket call affects socket descriptor 0 - the host server's socket. Programmers must guard against this error. Consider initializing the socket descriptor variable to -1 and checking for greater than or equal before making a socket call.

[{"Product":{"code":"SWG60","label":"IBM i"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Host Servers","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"Version Independent","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]

Historical Number

26983119

Document Information

Modified date:
01 January 2020

UID

nas8N1016977