gsk_secure_soc_write()--Send data on a secure session


  Syntax
 #include <gskssl.h>

 int gsk_secure_soc_write(gsk_handle my_session_handle,  
                         char *writeBuffer,
                         int writeBufSize,
                         int *amtWritten);

  Service Program Name: QSYS/QSOSSLSR

  Default Public Authority: *USE

  Threadsafe: Yes

The gsk_secure_soc_write() function is used by a program to write data on a secure session.


Parameters

my_session_handle (Input) 
The handle, returned from gsk_secure_soc_open() and used on the gsk_secure_soc_init() API call that initialized the secure session over which data is to be written.

writeBuffer (Input) 
The pointer to the user-supplied buffer from which the data is to be written.

writeBufSize (Input) 
The number of bytes to be written.

amtWritten (Output) 
The number of bytes written as a result of this API call.

Authorities

No authorization is required.


Return Value

gsk_secure_soc_write() returns an integer. Possible values are:

[GSK_OK]

gsk_secure_soc_write() was successful.

[GSK_INVALID_HANDLE]

The handle specified was not valid.

[GSK_INVALID_STATE]

The handle is not in the correct state for this operation.

[GSK_INVALID_BUFFER_SIZE]

The readBufSize is less than 1.

[GSK_WOULD_BLOCK]

Operation would have caused the process to be suspended.

[GSK_ERROR_SOCKET_CLOSED]

A close() was done on the socket descriptor for this secure session.

[GSK_AS400_ERROR_CLOSED]

The secure session was closed by another thread before the write completed.

[GSK_AS400_ERROR_INVALID_POINTER]

The writeBuffer or amtWritten pointer is not valid.

[GSK_INTERNAL_ERROR]

An unexpected error occurred during SSL processing.

Start of change[GSK_ERROR_SSL_CLOSED]

A gsk_secure_soc_misc(GSK_CLOSE_NOTIFY) was previously performed on this secure session.

[GSK_ERROR_SEQNUM_EXHAUSTED]

A secure connection using TLSv1.1 or higher protocol has sent or received more than 264-1 SSL records. To prevent this error perform a gsk_secure_soc_misc(GSK_RESET_CIPHER) operation before the record limit is reached. A general guideline would be once a day for long lived secure connections.

End of change
[GSK_ERROR_IO]

An error occurred in SSL processing; check the errno value.


Error Conditions

When the gsk_secure_soc_write() API fails with return code [GSK_ERROR_IO], errno can be set to:

[EIO]

Input/output error.

[ENOTCONN]

Requested operation requires a connection.

[ENOTSOCK]

The specified descriptor does not reference a socket.

[EPIPE]

Broken pipe.

[EUNATCH]

The protocol required to support the specified address family is not available at this time.

Any errno that can be returned by send() can be returned by this API. See Sockets APIs for a description of the errno values it can return.


Usage Notes

  1. There is no maximum length of the data that can be written.

  2. It is strongly suggested that you do not mix the gsk_secure_soc_write() API with any of the sockets write functions. SSL and socket reads and writes can be mixed, but they must be performed in matched sets. If a client application writes 100 bytes of data using one or more of the socket send() calls, then the server application must read exactly 100 bytes of data using one or more of the socket recv() calls. This is also true for gsk_secure_soc_write() API.

  3. The amtWritten value is set to zero when return value is not GSK_OK.

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.

Related Information



API introduced: V5R1
Top | UNIX-Type APIs | APIs by category