The srx_np callable service sends or receives data on a socket using CSM (Communications Storage Manager) buffers.
Operation | Environment |
---|---|
Authorization: | Supervisor state or problem state, any PSW key |
Dispatchable unit mode: | Task SRB - AF_INET/AF_INET6 socket support only |
Cross memory mode: | PASN = HASN |
AMODE (BPX1SRX): | 31-bit task or SRB mode |
AMODE (BPX4SRX): | 64-bit SRB mode only |
ASC mode: | Primary mode |
Interrupt status: | Enabled for interrupts |
Locks: | Unlocked |
Control parameters: | All parameters must be addressable by the caller and in the primary address space. |
|
AMODE 64 callers use BPX4SRX with the same parameters. All addresses in the Msghrdx structure are 31-bit pointers.
The name of a fullword that contains the socket file descriptor for which the srx_np service is requested.
The name of a field that contains the length of the Msghdrx parameter.
Before the data structures are built for the first time, you can use a value of 0 in this field to determine whether the operation is supported on a given socket. If the operation is supported, a Return_value of 0 is returned. If the operation is not supported, a Return_value of -1 with a Return_code of ENOSYS is returned.
The name of the MSGX structure that contains the information for this operation. See the usage notes and the BPXYMSGX macro (BPXYMSGX — Map the message header) for more information about the MSGX structure.
Return_code | Explanation |
---|---|
ENOSYS | This function is not supported on the specified socket. |
EAFNOSUPPORT | The address family that was specified in the message header is not the same as the address family that owns the socket. |
EBADF | An incorrect file descriptor was specified. The following reason codes can accompany the return code: JRFileDesNotInUse, JRFileNotOpen. |
ECONNRESET | The connection was reset by a peer. The following reason code can accompany the return code: JRSockNotCon. |
EINTR | A signal interrupted the srx_np service before any data was written. The following reason code can accompany the return code: JRSockRdwrSignal. |
EINVAL | An input parameter was incorrect. The following reason codes can accompany the return code: JRInvalidMsgh, JRSocketCallParmError, and JRSockNoName. |
EMSGSIZE | The message is too large to be sent all at once, as the socket requires. The following reason code can accompany the return code: JRSockBufMax. |
EFAULT | An address that was passed pointed to storage that could not be accessed. |
ENOTCONN | The socket was not connected. The following reason code can accompany the return code: JRSocketNotCon. |
ENOTSOCK | Socket_descriptor does not refer to a valid socket descriptor. The following reason code can accompany the return code: JRMustBeSocket. |
EPIPE | An attempt was made to send a message to a socket that is shut down or closed. This error also generates a SIGPIPE signal. The following reason code can accompany the return code: JRSocketClosed. |
EWOULDBLOCK | For a receive operation, the socket is marked nonblocking and there is no data available to be read, or the SO_RCVTIMEO timeout value was reached before data was available. The following reason codes can accompany the return code: JRWouldBlock, JrTimeOut. |
The name of a fullword in which the srx_np service stores the reason code. The srx_np service returns Reason_code only if Return_value is -1. Reason_code further qualifies the Return_code value. For the reason codes, see z/OS UNIX System Services Messages and Codes.
The srx_np service provides a way to send these buffers on a socket session. It is assumed that the application has its own interactions with CSM that allow it to obtain and free these buffers independently from the srx_np service. CSM is restricted to authorized programs, and the buffers are in key 6 storage. The srx_np service, however, may be invoked from problem state or authorized programs. All parameters are in local application storage and the caller's key.
For more information about CSM, see z/OS Communications Server: CSM Guide.
If data has not arrived yet, the request is suspended or failed with EWOULDBLOCK, as for any other socket receive type of operation.
When data is to be returned to the application, the transport assigns ownership of the CSM buffers to the application, and the application's Msghdrx structure is filled in with a description of the IOVX array buffer.
Field | Description |
---|---|
MsgxNamePtr | A pointer to a sockaddr buffer in which the system returns
the source address of the data that is received. This field is optional. If it is not used, MsgxNamePtr or MsgxnameLen should be zero. |
MsgxNameLen | The length of the sockaddr buffer that is pointed to by MsgxNamePtr. |
MsgxIovx | An IVTBUFL structure in which the system describes the CSM
buffer containing the IOVX array being returned for this request.
This CSM buffer is obtained by the system and freed by the calling
application. The IOVX array contains IVTBUFL structures, each of which describes a CSM data buffer that contains the data received by this request. The CSM data buffers that are used by this service are obtained by the system and freed by the caller. |
MsgxMsgFlags | MSG_* flags for this operation. Refer to BPXYMSGF — Map the message flags. |
MsgxFlags | Control flags:
If neither flag is specified, the application can handle CSM buffers in either ECSA or a data space. |
MsgxDataLen | The maximum or minimum amount of data that is to be received:
You can use this value to control the amount of data that is received, in the same way that you use the Buffer_length parameter of the recv service. If this field is 0, the receive operation completes as soon as the first block of data is available, and whatever data is available is returned. If the receive operation cannot be completed immediately, the application blocks or receives an EWOULDBLOCK error, depending on its blocking state. |
MsgxTcb | The TCB address of a task with which the CSM storage is to
be associated. By default the storage is associated with the calling
task. This field is optional, and should be 0 if not specified. |
Field | Description |
---|---|
MsgxNamePtr | A pointer to a sockaddr buffer that contains the destination
address for the send operation. This field is optional. If it is not used, MsgxNamePtr or MsgxNameLen should be 0. |
MsgxNameLen | The length of the sockaddr buffer that is pointed to by MsgxNamePtr. |
MsgxIovx | An IVTBUFL structure that describes the buffer containing the
IOVX array. This buffer may be a CSM buffer, or it may be in the caller's
storage. Ownership of a CSM buffer used for the IOVX array remains
with the application. The IOVX array contains IVTBUFL structures, each of which describes a CSM data buffer that contains the data to be sent. The CSM data buffers that are used by this service are obtained by the caller and freed by the system. |
MsgxMsgFlags | MSG_* flags for this operation. Refer to BPXYMSGF — Map the message flags. |
MsgxIVTBUFLOffset | The returned offset of the IOVX array entry for the first CSM data buffer that the application still owns. After a successful send, this value is equal to the length of the IOVX array. If this value is zero, no buffers were taken. |
MsgxErrIovx | The offset of the IOVX array entry that is in error. This field and MsgxErrData are returned only when there is an error that is specifically related to one of the IOVX entries or their associated buffers. Refer to the Return_code and Reason_code for details on the error. |
MsgxErrData | The amount of data that has been sent successfully from the buffer that is indicated by MsgxErrIovx. |
MsgxErrIovx and MsgxErrData should only be examined when the request completes with a Return_value of -1, or when the amount of data sent is less than the amount of data that was requested to be sent.
Note, however, that this program would simply be making C calls to the srx_np callable service, and not making normal C functional references. In particular, the return value and errno value would be returned in explicit calling parameters, rather than in the standard C method.
When the socket is associated to a specific transport, the requests are accepted or rejected based on that transport's support for CSM buffers. A socket becomes associated with a specific transport by being a connected stream socket, bound to a specific IP address, or through setibmopt(IBM_IMAGE) or ioctl(SIOCSETRTTD).
When the application's socket is associated with more than one transport, every associated transport must support CSM buffers for a receive operation to be accepted. For a send operation, the transport chosen by the system for the destination IP address must support CSM buffers.
recvmsg (BPX2RMS, BPX4RMS) — Receive messages on a socket and store them in message buffers
There are no restrictions on the use of the srx_np service.
For an example using this callable service, see BPX1SRX (srx_np) example.