SendWithLineEnd (Socket function): Difference between revisions
mNo edit summary |
m (link repair) |
||
(One intermediate revision by one other user not shown) | |||
Line 8: | Line 8: | ||
The <var>SendWithLineEnd</var> function, which may be invoked with a <var>Call</var> statement, | The <var>SendWithLineEnd</var> function, which may be invoked with a <var>Call</var> statement, | ||
has an effect similar to <var>[[$ | has an effect similar to <var>[[$Sock_SendLn]]</var>. | ||
==Syntax== | ==Syntax== | ||
Line 67: | Line 67: | ||
==Examples== | ==Examples== | ||
The following example uses a combination of <var>Send</var> and <var>SendWithLineEnd</var>. | The following example uses a combination of <var>Send</var> and <var>SendWithLineEnd</var>. | ||
<p class="code"> ... | <p class="code">... | ||
%domain = 'www.sirius-software.com' | %domain = 'www.sirius-software.com' | ||
%page = 'main.html' | %page = 'main.html' | ||
Line 77: | Line 77: | ||
%rc = %socket:SendWithLineEnd(' HTTP/1.0') | %rc = %socket:SendWithLineEnd(' HTTP/1.0') | ||
%rc = %socket:SendWithLineEnd('') | %rc = %socket:SendWithLineEnd('') | ||
... | |||
</p> | </p> | ||
In this example, the <var>Set</var> method specifies a line-end string of | In this example, the <var>Set</var> method specifies a line-end string of |
Latest revision as of 21:42, 17 December 2014
Send a string plus line end character (Socket class)
This method sends a string and an untranslated line-end string
over a Janus Sockets connection.
The line-end string may be set on the port definition
via the Set method or as an argument
on the SendWithLineEnd function.
The SendWithLineEnd function, which may be invoked with a Call statement, has an effect similar to $Sock_SendLn.
Syntax
[%number =] socket:SendWithLineEnd( string, [[Options=] string])
Syntax terms
%number | If specified, this is a numeric variable to contain the returned indicator of success of the function. The return value is either of these:
| ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
socket | A variable or an expression that is a reference to a Socket object. | ||||||||||
string | The string to send. | ||||||||||
Options | This optional, name allowed, argument is an option string that may contain any of the following:
|
Usage notes
- Whether it's set on the port definition, via the Set method, or as an argument
on the SendWithLineEnd function, LINEND must not be
NONE
when using SendWithLineEnd.
Examples
The following example uses a combination of Send and SendWithLineEnd.
... %domain = 'www.sirius-software.com' %page = 'main.html' %socket is Object Socket %socket = New('TEST', %domain) %socket:Set('LINEND', '0D0A') %socket:Send('GET /') %rc = %socket:Send(%page) %rc = %socket:SendWithLineEnd(' HTTP/1.0') %rc = %socket:SendWithLineEnd() ...
In this example, the Set method specifies a line-end string of
hexadecimal '0D0A'.
Then, lines are sent for which the protocol does not require
line-end delimiters: the "GET," and the HTML page defined
in %page
.
Then the SendWithLineEnd function sends
the HTTP specification with a line-delimiter.
This example highlights the fact that the programmer needs to know the requirements of the communication protocol before they know the appropriate method to use to send strings to the socket.