Simplified documentation of send().

This commit is contained in:
Diego Nehab 2005-11-24 20:29:28 +00:00
parent 7dace4af7e
commit 96da86a81f

View File

@ -331,34 +331,17 @@ substring to be sent.
</p> </p>
<p class=return> <p class=return>
If successful, the method returns the number of bytes sent. If successful, the method returns the index of the last byte
In case of error, the method returns within <tt>[i, j]</tt> that has been sent. Notice that, if
<b><tt>nil</tt></b>, followed by an error message, followed by the <tt>i</tt> is 1 or absent, this is effectively the total
index of the first character within <tt>[i, j]</tt> that has not been sent yet number of bytes sent. In case of error, the method returns
(you might want to try again from then on). The error message can be '<tt>closed</tt>' in case <b><tt>nil</tt></b>, followed by an error message, followed
the connection was closed before the transmission was completed or the by the index of the last byte within <tt>[i, j]</tt> that
string '<tt>timeout</tt>' in case there was a timeout during the has been sent. You might want to try again from the byte
operation. following that. The error message can be '<tt>closed</tt>'
</p> in case the connection was closed before the transmission
was completed or the string '<tt>timeout</tt>' in case
<p class=note> there was a timeout during the operation.
<b>Important note</b>:
The return values for the <tt>send</tt> method have been changed in
LuaSocket 2.0 alpha <b>and again</b> in the beta (sorry)!
In previous versions, the method returned only the
error message. Since returning <b><tt>nil</tt></b> in case of success was
nonsense, in alpha the first return value became the number of bytes sent.
Alas, it wasn't returning <tt><b>nil</b></tt> in case of
error. So it was changed again in beta.
</p>
<p class=note>
<b>Also important</b>:
In order to better support non-blocking I/O and to discourage
bad practice, the <tt>send</tt> method now only sends one string
per call. The other optional arguments allow the user to select
a substring to be sent in a much more efficient way than
using <tt>string.sub</tt>.
</p> </p>
<p class=note> <p class=note>