Send (Socket function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
Line 1: Line 1:
{{Template:Socket:Send subtitle}}
{{Template:Socket:Send subtitle}}


This method sends a string over a <var class="product">Janus Sockets</var> connection.
This [[Notation conventions for methods#Callable functions|callable]] method sends a string over a <var class="product">Janus Sockets</var> connection.
The <var>Send</var> function, which may be invoked with a <var>Call</var> statement, 
The <var>Send</var> function has an effect similar to <var>[[$Sock_Send]]</var>.                                   
has an effect similar to <var>[[$Sock_Send]]</var>.                                   


==Syntax==
==Syntax==
{{Template:Socket:Send syntax}}
{{Template:Socket:Send syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%number</th><td>number</td></tr>
<tr><th>%number</th>
<td>This is a numeric variable to contain the returned indicator of success of the function.
The return value is either of these:
<table>
<tr><th>0</th>
<td>The function completed successfully.</td></tr>
<tr><th>-1 </th>
<td>The socket is not open, and <code>ONRESET CONTINUE</code> is in effect for the socket.</td></tr>
</table></td></tr>
 
<tr><th>socket</th>
<tr><th>socket</th>
<td>A variable or an expression that is a reference to a <var>Socket</var> object.</td></tr>
<td>A variable or an expression that is a reference to a <var>Socket</var> object.</td></tr>
<tr><th>string</th>
<tr><th>string</th>
<td>string</td></tr>
<td>The string to send.</td></tr>
 
<tr><th><var>Options</var></th>
<tr><th><var>Options</var></th>
<td>string</td></tr>
<td>This optional argument is an option string that may contain any
of the following:
<table class="syntaxTable">
<tr><th><var>BINARY</var></th>
<td>Regardless of whether the <var>BINARY</var> or <var>CHAR</var> parameter is in effect for the socket's port, data <b>is not translated</b> when sent. The argument can be the result of a previous translation using the <var>[[TranOut (Socket function)|TranOut]]</var> method.</td></tr>
 
<tr><th><var>CHAR</var></th>
<td>Regardless of whether the <var>[[BINARY]]</var> or <var>[[CHAR]]</var> parameter is in effect for the socket's port, data <b>is translated</b> when sent. The translation is specified by the output table defined by the socket's <var>[[XTAB]]</var> parameter.</td></tr>
 
<tr><th><var>FIN</var></th>
<td>After <var class="term">string</var> is sent, no more data will be sent on the socket. This transmits the <code>FIN</code> indication to the remote partner.
<p>Note that when <code>FIN</code> is sent, print capturing is automatically turned <var>OFF</var> for the socket.</p></td></tr>
 
<tr><th><var>PUSH</var></th>
<td>Ensures that the data being sent on the socket is immediately sent to the receiver. Normally, data to be sent is buffered and may not be sent immediately.
<p> Using <var>PUSH</var> is <b>not</b> necessary if: </p>
<ul>
<li>You are specifying <code>FIN</code>, since a push operation is implied by <var>FIN</var>.
<li>You are alternating sends and receives on a socket, since receive-processing methods (<var>[[Receive (Socket function)|Receive]]Receive</var> and <var>[[ReceiveAndParse (Socket function)|ReceiveAndParse]]</var>) always do a push before receiving.
</ul></td></tr></table>
</td></tr>
</table>
</table>
==Usage notes==
<ul>
<li>If you need to send line-end delimited information, use the <var>[[SendWithLineEnd (Socket function)|SendWithLineEnd]]</var> method.
</ul>


==Usage notes==
==Examples==
==See also==
==See also==
{{Template:Socket:Send footer}}
{{Template:Socket:Send footer}}

Latest revision as of 19:04, 11 June 2012

Send a string over this socket (Socket class)


This callable method sends a string over a Janus Sockets connection. The Send function has an effect similar to $Sock_Send.

Syntax

[%number =] socket:Send( string, [[Options=] string])

Syntax terms

%number This is a numeric variable to contain the returned indicator of success of the function.

The return value is either of these:

0 The function completed successfully.
-1 The socket is not open, and ONRESET CONTINUE is in effect for the socket.
socket A variable or an expression that is a reference to a Socket object.
string The string to send.
Options This optional argument is an option string that may contain any

of the following:

BINARY Regardless of whether the BINARY or CHAR parameter is in effect for the socket's port, data is not translated when sent. The argument can be the result of a previous translation using the TranOut method.
CHAR Regardless of whether the BINARY or CHAR parameter is in effect for the socket's port, data is translated when sent. The translation is specified by the output table defined by the socket's XTAB parameter.
FIN After string is sent, no more data will be sent on the socket. This transmits the FIN indication to the remote partner.

Note that when FIN is sent, print capturing is automatically turned OFF for the socket.

PUSH Ensures that the data being sent on the socket is immediately sent to the receiver. Normally, data to be sent is buffered and may not be sent immediately.

Using PUSH is not necessary if:

  • You are specifying FIN, since a push operation is implied by FIN.
  • You are alternating sends and receives on a socket, since receive-processing methods (ReceiveReceive and ReceiveAndParse) always do a push before receiving.

Usage notes

  • If you need to send line-end delimited information, use the SendWithLineEnd method.

See also