Previous Page Contents Page Next Page

3.4 lu0_write

The lu0_write function sends data from the LU0 application's LU to the host. LU0 sends the data to the host as a chain, splitting it into multiple RUs if necessary.

3.4.1 Function Call

     int lu0_write (
                    AP_UINT32    *handle,
                    int           options,
                    LU0_CALLBACK  callback,
                    void         *user,
                    int           buffer_length,
                    char         *buffer,
                    int          *qualifier
                   );

3.4.2 Supplied Parameters

The application supplies the following parameters:

handle

The identifier that was returned on the original lu0_init function call for the LU0 session.

options

Reserved (this parameter must be set to zero).

callback

To use the synchronous version of lu0_write, specify a NULL pointer.

To use the asynchronous version of lu0_write, specify a pointer to a callback routine within the application. See Synchronous and Asynchronous LU0 Operation for more details.

user

This parameter is used only for asynchronous calls.

A pointer to an optional user data string supplied by the application; typically used for the application's session identifier or for a pointer to a control block. The format of this data is defined by the application; SNAP-IX does not use this data, but returns it unchanged as a parameter to the callback routine when returning information related to this function call. This allows the application to correlate the callback with the original request.

buffer_length

The length in bytes of the supplied data buffer. To send a null RU chain, specify a length of zero.

buffer

Address of a data area containing the data to be sent. If buffer_length is zero, the application can supply a NULL pointer.

If the application uses the asynchronous version of lu0_write , the data area must remain valid until the callback function has completed. This means that the data area must not be declared on the stack.

LU0 does not modify the supplied data.

3.4.3 Returned Parameters: Asynchronous Operation

If a callback routine was specified, the function does not block, and returns a value to indicate whether the function was issued successfully. If it was successful, the result of the write operation is then reported using the application's callback routine.

Return Value

The function returns one of the following values:

LU0_EVENT_IN_PROGRESS

The function was issued successfully. The result of sending the data (or a session failure event if this occurs first) will be reported to the application using the supplied callback routine.

LU0_EVENT_WRITE_BAD

LU0 could not process the function, either because the application supplied parameters that were not valid (for example, it tried to issue a second lu0_write before the first has completed) or because an error occurred within SNAP-IX. The SNAP-IX error log file contains more details of the error. The supplied callback routine will not be called for this function. No data was sent.

Returned Parameters

The asynchronous version of lu0_write does not return any parameters. The application can supply a null pointer for the qualifier parameter.

Parameters Supplied to Callback Routine

If the return value from the lu0_write function is LU0_EVENT_IN_PROGRESS, LU0 calls the application's callback routine when the data has been sent (and a response has been received if the application required one), or to report a subsequent session failure. The parameters supplied to the callback routine are as follows.

handle

The session handle that was returned on the lu0_init function.

user

The user data that was supplied on the lu0_write function. This allows the application to correlate the callback with the original request.

event

The event being reported. This is one of the following:

LU0_EVENT_WRITE_OK

The data has been sucessfully sent to the host (and a response has been received if the application required one). The application can re-use or free the data buffer, either within the callback routine or in the main processing path.

Note

This return code does not imply that the host sent a positive response to the data. If the application used the LU0_OPTION_USE_RQD option on the lu0_init function, to request definite responses to all RUs, the qualifier parameter to the callback function contains the SNA sense code sent by the host in its response. Otherwise, responses are not passed to the application.

LU0_EVENT_WRITE_SESS_FAIL

The application issued lu0_term (or lu0_init to restart the session) while lu0_write was outstanding. No data will be returned.

The session termination event is reported to the lu0_write function's callback routine to ensure that the routine is always called once, and to allow the application to do any cleanup processing specific to this routine.

qualifier

If the application used the LU0_OPTION_USE_RQD option on the lu0_init function, to request definite responses to all RUs, this parameter contains the 4-byte SNA sense code sent by the host in its response. A value of zero indicates a positive response. Otherwise this parameter is not used.

3.4.4 Returned Parameters: Synchronous Operation

If a callback routine was not specified, the function blocks until the data has successfully been sent to the host (and, if the application used the LU0_OPTION_USE_RQD option on the lu0_init function, until the host has sent a response). It then returns with a value indicating whether the data was sent successfully.

Return Value

The function returns one of the following values:

LU0_EVENT_WRITE_OK

The data has been sucessfully sent to the host (and a response has been received if the application required one).

Note

This return code does not imply that the host sent a positive response to the data. If the application used the LU0_OPTION_USE_RQD option on the lu0_init function, to request definite responses to all RUs, the qualifier parameter contains the SNA sense code sent by the host in its response. Otherwise, responses are not passed to the application.

LU0_EVENT_WRITE_BAD

LU0 could not process the function, either because the application supplied parameters that were not valid or because an error occurred within SNAP-IX. The SNAP-IX error log file contains more details of the error. The data was not sent.

LU0_EVENT_WRITE_SESS_FAIL

The session failed, or an UNBIND was received from the host, before lu0_write was issued or while it was outstanding.

The application must not issue any further lu0_write calls. It may issue lu0_read calls, typically with the LU0_OPTION_READ_NO_WAIT option set, to receive any data that is queued within LU0. After dealing with any outstanding data, it can either terminate the session or restart it.

  • To terminate the session, it issues lu0_term.

  • To restart the session, it issues lu0_init using the existing session handle and LU name.

LU0_EVENT_WRITE_SHUTD

The data was sent successfully, and the host has sent SHUTD.

The application can use further lu0_write function calls to send any outstanding data. It can also issue lu0_read calls, typically with the LU0_OPTION_READ_NO_WAIT option set, to receive any data that is queued within LU0, until it receives a return value of LU0_EVENT_NO_DATA to indicate the end of the queued data. It must then either terminate the session or restart it. The host will expect the application to do this quickly.

  • To terminate the session, it issues lu0_term.

  • To restart the session, it issues lu0_init using the existing session handle and LU name.

Returned Parameters

LU0 returns the following parameters.

qualifier

This parameter contains an SNA sense code if one of the following is true:

  • If the return value is LU0_EVENT_WRITE_SESS_FAIL , this parameter contains the SNA sense code or LU0-specific sense code associated with the failure, if one is available.

  • If the return value is LU0_EVENT_WRITE_OK or LU0_EVENT_WRITE_SHUTD, and the application used the LU0_OPTION_USE_RQD option on the lu0_init function to request definite responses to all RUs. In this case, the qualifier parameter contains the 4-byte SNA sense code sent by the host in its response. A value of zero indicates a positive response.

In all other cases, this parameter is not used.

Previous Page Contents Page Top of Page Next page