z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


maxdesc()

z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
SC27-3660-00

The maxdesc() call reserves additional space in the TCP/IP address space to allow socket numbers to extend beyond the default range of 0 through 49. Socket numbers 0, 1, and 2 are never assigned, so the default maximum number of sockets is 47.

#include <manifest.h>
#include <bsdtypes.h>
#include <socket.h>
#include <in.h>
 
int maxdesc(int *totdesc, int *inetdesc)
Parameter
Description
totdesc
Points to an integer containing a value one greater than the largest socket number desired. The maximum allowed value is 2000.
Note: If a totdesc value greater than 2000 is specified, the internal value is set to 2000. In all cases, use getdtablesize() to verify the value set by maxdesc().
inetdesc
Points to an integer containing a value one greater than the largest socket number desired. The maximum value, usable for AF_INET sockets, allowed is 2000.
Set the integer pointed to by totdesc to one more than the maximum socket number desired. If your program does not use AF_INET sockets, set the integer pointed to by inetdesc to 0 . If your program uses AF_INET sockets, set the integer pointed to by inetdesc to the same value as totdesc; maxdesc() must be called before your program creates its first socket. Your program should use getdtablesize() to verify that the number of sockets has been changed.
Note: Increasing the size of the bit sets for the select() call must be done at compile time. To increase the size of the bit sets, before including BSDTYPES.H, define FD_SETSIZE to be the largest value of any socket. The default size of FD_SETSIZE is 255 sockets.

Return values

The value 0 indicates success. (Your application should check the integer pointed to by inetdesc. It might contain less than the original value, if there was insufficient storage available in the TCP/IP address space. In this case, the desired number of AF_INET sockets are not available.) The value -1 indicates an error. Errno identifies the specific error.
Errno
Description
EFAULT
Using the totdesc or inetdesc parameters as specified results in an attempt to access storage outside of the caller address space, or storage not able to be modified by the caller.
EALREADY
Your program called maxdesc() after creating a socket, or after a previous call to maxdesc().
EINVAL
Indicates that *totdesc is less than *inetdesc; *totdesc is less than or equal to 0; or *inetdesc is less than 0.
ENOMEM
Your address space lacks sufficient storage.

Example

int totdesc, inetdesc;
totdesc = 100;
inetdesc = 0;
rc = maxdesc(&totdesc, &inetdesc)
If successful, your application can create 97 sockets, all of type AF_IUCV. Socket numbers run from 3–99.
int totdesc, inetdesc;
totdesc = 100;
inetdesc = 100;
rc = maxdesc(&totdesc, &inetdesc)

If successful, your application can create 97 sockets, each of which can be of type AF_INET or AF_IUCV. The socket numbers run from 3–99.

Related calls

select(), socket(), getdtablesize()

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014