$Sock SendLn: Difference between revisions
mNo edit summary |
m (1 revision) |
(No difference)
|
Revision as of 02:53, 20 January 2012
Send string followed by LINEND
Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is currently no direct OO equivalent for this $function.
$Sock_SendLn sends an argument string and the untranslated LINEND string over a Janus Sockets connection.
It is also a callable function.
Syntax
[%rc =] = $Sock_SendLn(sockNum, string, [opts])
Syntax terms
%rc | A numeric error code (described further below), or if the operation could not be performed as requested, a 0 value. For more details, see "$Sock_RecvPrs return values". | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
sockNum | The socket number. | ||||||||||
string | The string to send. Model 204 limits this to a length of 255 bytes. | ||||||||||
opts | This optional argument is an option string, which can contain any of the following:
|
Usage notes
- Whether it is set on the port definition, via $Sock_Set, or as an argument on the $Sock_SendLn function, LINEND must not be NONE when using $Sock_SendLn.
- These are the $Sock_SendLn return codes:
- 0, if the function completes successfully.
- -1, if the socket is not open and ONRESET CONTINUE is in effect for the socket.
Example
The following example uses a combination of $Sock_Send and $Sock_SendLn.
%domain = 'www.sirius-software.com' %page = 'main.html' %socket = $Sock_Conn('TEST', %domain) %s = $Sock_Set(%socket, 'LINEND', '0D0A') %rc = $Sock_Send(%socket, 'GET /') %rc = $Sock_Send(%socket, %page) %rc = $Sock_SendLn(%socket, ' HTTP/1.0') %rc = $Sock_SendLn(%socket, )
In this example, $Sock_Set is used to specify a line-end string of hexadecimal '0D0A'. Then, a few lines are sent for which the protocol does not require line-end delimiters: the GET /
and the name of the HTML page defined in %page
. Then the HTTP specification is sent with a line-delimiter via the $Sock_SendLn function.
This example highlights the fact that the programmer needs to know the requirements of the communication protocol they are using before they know the appropriate function to use in sending strings to the socket.