takedescriptor()--Receive Socket Access from Another Job


Syntax
#include <sys/types.h>
#include <sys/socket.h>

int takedescriptor(char *source_job)


Threadsafe: Yes

The takedescriptor() function is used to obtain a descriptor in one OS/400 job which was passed from another OS/400 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.

Return Value

takedescriptor() returns an integer. Possible values are:

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

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

  1. 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().

  2. 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.

  3. If no descriptor is available to be received, the takedescriptor() is blocked.

  4. 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.

  5. 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.

  6. For files and directories, takedescriptor() is only supported for objects in the root and QOpenSys file systems.

Related Information


Top | Sockets APIs | APIs by category


[Information Center Home Page | Feedback ] [Legal | AS/400 Glossary]