z/OS Communications Server: IP Programmer's Guide and Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


The DPIget_fd_for_handle() function

z/OS Communications Server: IP Programmer's Guide and Reference
SC27-3659-02

Format

#include <snmp_dpi.h>
 
int DPIget_fd_for_handle(       /* get the file descriptor    */
  int            handle);       /* for this handle            */

Parameters

handle
A handle that was obtained with a DPIconnect_to_agent_xxxx() call.

Return codes

If successful, a positive integer representing the file descriptor associated with the specified handle.

If not successful, a negative integer is returned, which indicates the error that occurred. See Return codes from DPI transport-related functions for a list of possible error codes.

DPI_RC_INVALID_HANDLE
A bad handle was passed as input. Either the handle is not valid, or it describes a connection that has been disconnected.

Usage

The DPIget_fd_for_handle function is used to obtain the file descriptor for the handle, which was obtained with a DPIconnect_to_agent_TCP() call or a DPIconnect_to_agent_UNIXstream() call.

Using this function to retrieve the file descriptor associated with your DPI connections enables you to use either the select or selectex socket calls. Using selectex enables your program to wait for event control blocks (ECBs), in addition to a read condition. This is one example of how an MVS™ application can wait for notification of the receipt of a modify command (through an ECB post) or DPI packet at the same time.

Examples

#include <snmp_dpi.h>
#include /* other include files for BSD sockets and such */
int                  handle;
int                  fd;
 
handle = DPIconnect_to_agent_TCP("127.0.0.1","public");
if (handle < 0) {
   printf("Error %d from connect\n",handle);
   exit(1);
}
fd = DPIget_fd_for_handle(handle);
if (fd <0) {
   printf("Error %d from get_fd\n",fd);
   exit(1);
}

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014