ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/sslwrite.htm

374 lines
9.4 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
<title>SSL_Write()--Write Data to an SSL-Enabled Socket Descriptor</title>
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<!-- Begin Header Records ========================================== -->
<!-- Direct1 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
<!--End Header Records -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<a name="Top_Of_Page"></a>
<!-- Java sync-link -->
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
</script>
<h2>SSL_Write()--Write Data to an SSL-Enabled Socket Descriptor</h2>
<div class="box" style="width: 60%;">
<br>
&nbsp;&nbsp;Syntax<br>
<pre>
#include &lt;qsossl.h&gt;
int SSL_Write(SSLHandle *<em>handle</em>,
void *<em>buffer</em>,
int <em>buffer_length</em>)
</pre>
<br>
&nbsp;&nbsp;Service Program Name: QSOSSLSR<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Default Public Authority: *USE<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Threadsafe: Yes<br>
<!-- iddvc RMBR -->
<br>
</div>
<p>The <strong><em>SSL_Write()</em></strong> function is used by a program to
write data to an SSL-enabled socket descriptor.</p>
<br>
<h3>Parameters</h3>
<dl>
<dt>SSLHandle* <strong><em>handle</em></strong> &nbsp;(input)&nbsp;</dt>
<dd>The pointer to an <strong><em>SSLHandle</em></strong> for an SSL session.
An <strong><em>SSLHandle</em></strong> is a typedef for a buffer of type struct
<strong><em>SSLHandleStr</em></strong>. In <strong>&lt;qsossl.h&gt;</strong>,
struct <strong><em>SSLHandleStr</em></strong> is defined as the following:<br>
<br>
<table border cellpadding="5">
<tr>
<td><br>
<pre>
struct SSLHandleStr { /* SSLHandleStr */
int fd; /* Socket descriptor */
int createFlags; /* SSL_Create flags value */
unsigned protocol; /* SSL protocol version */
unsigned timeout; /* Timeout value in seconds */
unsigned char cipherKind[3]; /* Current 2.0 cipher suite*/
unsigned short int cipherSuite; /* Current 3.0 cipher suite */
unsigned short int* cipherSuiteList; /* List of cipher suites */
unsigned int cipherSuiteListLen; /* Number of entries in
the cipher suites list */
unsigned char* peerCert; /* Peer certificate */
unsigned peerCertLen; /* Peer certificate length */
int peerCertValidateRc; /* Return code from
validation of certficate */
int (*exitPgm)(struct SSLHandleStr* sslh);
/* Authentication exit
program called when a
certificate is received
during SSL handshake */
};
</pre>
</td>
</tr>
</table>
<br>
</dd>
<dt>void *<strong><em>buffer</em></strong> &nbsp;(input)&nbsp;</dt>
<dd>A pointer to the user-supplied buffer in which the data to be written is
stored.<br>
<br>
</dd>
<dt>int <strong><em>buffer_length</em></strong> &nbsp;(input)&nbsp;</dt>
<dd>The length of the <em>buffer</em>.</dd>
</dl>
<br>
<h3>Authorities</h3>
<p>No authorization is required.</p>
<br>
<h3>Return Value</h3>
<p><em>SSL_Write()</em> returns an integer. Possible values are:</p>
<dl>
<dt><em>[n]</em> </dt>
<dd>
<p>Successful, where n is the number of bytes written. </p>
</dd>
<dt><em>[SSL_ERROR_BAD_STATE]</em> </dt>
<dd>
<p>SSL detected a bad state in the SSL session. </p>
</dd>
<dt><em>[SSL_ERROR_CLOSED]</em> </dt>
<dd>
<p>The SSL session ended. </p>
</dd>
<dt><em>[SSL_ERROR_IO]</em> </dt>
<dd>
<p>An error occurred in SSL processing; check the <em>errno</em> value. </p>
</dd>
<dt><em>[SSL_ERROR_UNKNOWN]</em> </dt>
<dd>
<p>An unknown or unexpected error occurred during SSL processing.</p>
</dd>
</dl>
<br>
<h3>Error Conditions</h3>
<p>When the <em>SSL_Write()</em> API fails with return code [SSL_ERROR_IO],
<em>errno</em> can be set to to one of the following:</p>
<dl>
<dt><em>[EBADF]</em> </dt>
<dd>
<p>Descriptor not valid. </p>
</dd>
<dt><em>[EFAULT]</em> </dt>
<dd>
<p>Bad address.</p>
<p>One of the following conditions occurred:</p>
<ul>
<li>The system detected an address that was not valid while attempting to
access the <em>buffer</em> parameter.</li>
<li>The system detected an address that was not valid while attempting to
access the <em>handle</em> parameter or one of the address fields in the
<em>handle</em> parameter.</li>
</ul><br>
</dd>
<dt><em>[EINTR]</em> </dt>
<dd>
<p>Interrupted function call. </p>
</dd>
<dt><em>[EINVAL]</em> </dt>
<dd>
<p>Parameter not valid.</p>
<p>This error code indicates one of the following:</p>
<ul>
<li>The <em>socket_descriptor</em> type is not SOCK_STREAM or address family is
not AF_INET or AF_INET6.</li>
<li>One of the parameters passed is not valid or is NULL.</li>
<li>The <em>buffer_length</em> parameter specifies a negative value.</li>
</ul><br>
</dd>
<dt><em>[EIO]</em> </dt>
<dd>
<p>Input/output error. </p>
</dd>
<dt><em>[ENOBUFS]</em> </dt>
<dd>
<p>There is not enough buffer space for the requested operation. </p>
</dd>
<dt><em>[ENOTCONN]</em> </dt>
<dd>
<p>Requested operation requires a connection.</p>
<p>This error code indicates one of the following:</p>
<ul>
<li>The <em>socket_descriptor</em> is not for a socket that is in a connected
state.</li>
<li>The <em>socket_descriptor</em> has not had SSL support enabled. This
usually means that an <em>SSL_Create()</em> has not been completed for this
<em>socket_descriptor</em>.</li>
</ul><br>
</dd>
<dt><em>[ENOTSOCK]</em> </dt>
<dd>
<p>The specified descriptor does not reference a socket. </p>
</dd>
<dt><em>[EPIPE]</em> </dt>
<dd>
<p>Broken pipe. </p>
</dd>
<dt><em>[ETIMEDOUT]</em> </dt>
<dd>
<p>A remote host did not respond within the timeout period. </p>
</dd>
<dt><em>[EUNATCH]</em> </dt>
<dd>
<p>The protocol required to support the specified address family is not
available at this time. </p>
</dd>
<dt><em>[EUNKNOWN]</em> </dt>
<dd>
<p>Unknown system state.</p>
</dd>
<dt><em>[EWOULDBLOCK]</em> </dt>
<dd>
<p>Operation would have caused the thread to be suspended.</p>
</dd>
</dl>
<br>
<br>
<h3>Error Messages</h3>
<table width="100%" cellpadding="5">
<tr>
<th align="left" valign="top">Message ID</th>
<th align="left" valign="top">Error Message Text</th>
</tr>
<tr>
<td align="left" valign="top">CPE3418 E</td>
<td align="left" valign="top">Possible APAR condition or hardware failure.</td>
</tr>
<tr>
<td align="left" valign="top">CPF9872 E</td>
<td align="left" valign="top">Program or service program &amp;1 in library
&amp;2 ended. Reason code &amp;3.</td>
</tr>
<tr>
<td align="left" valign="top">CPFA081 E</td>
<td align="left" valign="top">Unable to set return value or error code.</td>
</tr>
</table>
<br>
<br>
<h3>Usage Notes</h3>
<ol>
<li>The <em>SSL_Write()</em> function is only valid on sockets that have an
address family of <samp>AF_INET</samp> or <samp>AF_INET6</samp> and a socket type of <samp>SOCK_STREAM</samp>. If the descriptor
pointed to by the <em>handle</em> structure parameter does not have the correct
address family and socket type, [SSL_ERROR_IO] is returned and the
<em>errno</em> value is set to EINVAL.<br>
<br>
</li>
<li>There is no maximum length of the data that can be written. However, SSL
will segment the data into multiple SSL record buffers if it will not fit in
one SSL record buffer. The maximum SSL record size is 32 KB minus the necessary
SSL record headers.<br>
<br>
</li>
<li>If the <em>createFlags</em> field in the <em>SSLHandle</em> specifies a
value that does not include the SSL_ENCRYPT flag, then this function will
simply call the sockets <em>write()</em> function.<br>
<br>
</li>
<li>Unpredictable results will occur when attempting to mix calls to
<em>SSL_Write()</em> and any of the sockets write functions (<em>send()</em>,
<em>write()</em>, <em>writev()</em>, and so forth). It is strongly suggested
that you do not mix the <em>SSL_Write()</em> API with any of the sockets write
functions.</li>
</ol>
<br>
<h3>Related Information</h3>
<ul>
<li><a href="sslcreat.htm">SSL_Create()</a>--Enable SSL Support for the Specified
Socket Descriptor<br>
<br>
</li>
<li><a href="ssldest.htm">SSL_Destroy()</a>--End SSL Support for the Specified SSL
Session<br>
<br>
</li>
<li><a href="sslhands.htm">SSL_Handshake()</a>--Initiate the SSL Handshake
Protocol<br>
<br>
</li>
<li><a href="sslinit.htm">SSL_Init()</a>--Initialize the Current Job for
SSL<br>
<br>
</li>
<li><a href="sslread.htm">SSL_Read()</a>--Receive Data from an SSL-Enabled Socket
Descriptor</li>
</ul>
<br>
<hr>
API introduced: V4R3
<hr>
<center>
<table cellpadding="2" cellspacing="2" align="center">
<tr align="center">
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a> </td>
</tr>
</table>
</center>
</body>
</html>