SendWithLineEnd (Socket function): Difference between revisions
m (→Syntax terms) |
m (→Syntax terms) |
||
Line 27: | Line 27: | ||
<tr><th>string</th> | <tr><th>string</th> | ||
<td>The string to send.</td></tr> | <td>The string to send.</td></tr> | ||
<tr><th> | <tr><th><var>Options</var></th> | ||
<td>This optional argument is an option string that may contain any of the following: | <td>This optional, [[Notation conventions for methods#Named parameters|name allowed]], argument is an option string that may contain any of the following: | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th><var>BINARY</var> </th> | <tr><th><var>BINARY</var> </th> |
Revision as of 22:20, 7 June 2012
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.
Example
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.