SendWithLineEnd (Socket function)
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
%rc | If specified, this is a numeric variable to contain the returned indicator of success of the function. The return value is either of these:
| ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
%socko | A variable or an expression that is a reference to a Socket object. | ||||||||||
string | The string to send. | ||||||||||
opt | This optional 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.