Send string followed by LINEND
Note: Many $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for $Sock_SendLn is the SendWithLineEnd method.
$Sock_SendLn sends an argument string and the untranslated LINEND string over a Janus Sockets connection.
It is also a callable function.
[%rc =] = $Sock_SendLn(sockNum, string, [opts])
|%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:
- 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.
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.