takedescriptor()--Receive Socket Access from Another Job
Syntax
#include <sys/types.h>
#include <sys/socket.h>
int takedescriptor(char *source_job)
Service Program Name: QSOSRV1
Default Public Authority: *USE
Threadsafe: Yes
The takedescriptor() function is used to obtain a descriptor in one
i5/OS job which was passed from another i5/OS job by a
givedescriptor().
Parameters
- source_job
- (Input) A pointer to the internal job identifier that identifies the source
job from which to receive a passed descriptor.
Authorities
No authorization is required.
Return Value
takedescriptor() returns an integer. Possible values are:
- -1 (unsuccessful)
- n (successful), where n is a descriptor.
Error Conditions
When takedescriptor() fails, errno can be set to one of
the following:
[EFAULT] |
Bad address.
The system detected an address which was not valid while attempting to
access the source_job parameter.
|
[EINVAL] |
Parameter not valid.
The source_job parameter points to data that is not valid.
|
[EMFILE] |
Too many descriptions for this process.
|
[EIO] |
Input/output error.
|
[EUNKNOWN] |
Unknown system state. |
Error Messages
Message ID |
Error Message Text |
CPE3418 E |
Possible APAR condition or hardware failure.
|
CPF9872 E |
Program or service program &1 in library
&2 ended. Reason code &3. |
CPFA081 E |
Unable to set return value or error code. |
Usage Notes
- This function can only obtain a descriptor if the sender of the descriptor
referenced the job that this takedescriptor() is issued in by
explicitly specifying this job's identification on the target_job
parameter of the givedescriptor().
- If the source_job parameter is a NULL pointer, then a descriptor
can be received from any job which issues a givedescriptor() that
references the job in which takedescriptor() is issued.
- If no descriptor is available to be received, the takedescriptor()
is blocked.
- If both the job in which the givedescriptor() is issued and the
job specified by the target_job parameter end while a descriptor is in
transit, the descriptor is reclaimed by the system, and the resource that it
represents is closed.
- The information to specify in the target_job parameter of the
givedescriptor() and in the source_job parameter of the
takedescriptor() can be obtained in the actual target job by using a
work management API (for example, QUSRJOBI) to retrieve the
internal job identifier.
- For files and directories, takedescriptor() is only supported for
objects in the
Root, QOpenSys, User-defined file systems (UDFS), and Network File System (NFS).
- If this function is called by a thread executing one of the scan-related exit programs (or any of its
created threads), it will fail with error code [ENOTSUP]. See Integrated File System Scan on Open Exit Programs and Integrated File System Scan on Close Exit Programs
for more information.
- When the descriptor is obtained using takedescriptor(), any information
accessed using that descriptor with the various read and write interfaces will
be in binary, even if the original descriptor's accesses would have had text
conversions occur. See
Using CCSIDs and code pages in the
open--Open file documentation for more information on text conversion.
Related Information
API introduced: V3R1