Janus Sockets $functions: Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 14: Line 14:
used: for example, a socket port must be connected before data is sent using it,
used: for example, a socket port must be connected before data is sent using it,
and data may not be sent after the <var>FIN</var> indicator is sent.
and data may not be sent after the <var>FIN</var> indicator is sent.
For more information about <var class="product">Janus Sockets</var> programming, see [[Janus Sockets User Language coding considerations|"Janus Sockets User Language coding considerations"]].
For more information about <var class="product">Janus Sockets</var> programming, see [[Janus Sockets User Language coding considerations]].
   
   
Sample programs using $functions are
Sample programs using $functions are
included in the appendix to this document and in the JANUS file
included in [[Sample Janus Sockets programs]] and in the JANUS file
distributed with this product.
distributed with this product.
   
   
==<var class="product">Janus Sockets</var> $function summary==
__TOC__
The <var class="product">Janus Sockets</var> <var class="product">User Language</var> $functions for communicating with remote
 
==Janus Sockets $function summary==
The <var class="product">Janus Sockets</var> <var class="product">SOUL</var> $functions for communicating with remote
hosts over TCP/IP are listed below and described individually in
hosts over TCP/IP are listed below and described individually in
sections that follow:
sections that follow:
<table>
<table>
<tr><th>$Sock_Capture
<tr><td>[[$Sock_Capture]]</td>
</th><td>Change print capture setting
<td>Change print capture setting</td></tr>
 
<tr><td>[[$Sock_Cert_Info]]</td>
<td>Get value of entity in partner's certificate
</td></tr>
</td></tr>
<tr><th>$Sock_Cert_Info
 
</th><td>Get value of entity in partner's certificate
<tr><td>[[$Sock_Cert_Levels]]</td>
<td>Get number of levels in partner's certificate
</td></tr>
</td></tr>
<tr><th>$Sock_Cert_Levels
 
</th><td>Get number of levels in partner's certificate
<tr><td>[[$Sock_Close]]</td>
<td>Terminate sending and receiving of data on, and remove from use, one or all <var class="product">Janus Sockets</var> connection(s)
</td></tr>
</td></tr>
<tr><th>$Sock_Close
 
</th><td>Terminate sending and receiving of data on, and remove from use, one or all <var class="product">Janus Sockets</var> connection(s)
<tr><td>[[$Sock_Conn]]</td>
<td>Create connection to remote host using CLSOCK port
</td></tr>
</td></tr>
<tr><th>$Sock_Conn
 
</th><td>Create connection to remote host using CLSOCK port
<tr><td>[[$Sock_ErrInfo]]</td>
<td>Get info about last <var class="product">Janus Sockets</var> error
</td></tr>
</td></tr>
<tr><th>$Sock_ErrInfo
 
</th><td>Get info about last <var class="product">Janus Sockets</var> error
<tr><td>[[$Sock_Info]]</td>
<td>Get info about socket
</td></tr>
</td></tr>
<tr><th>$Sock_Info
 
</th><td>Get info about socket
<tr><td>[[$Sock_Num]]</td>
<td>Get selected socket numbers</td></tr>
 
<tr><td>[[$Sock_OnReset]]</td>
<td>Set label to handle <var>RESET</var> conditions
</td></tr>
</td></tr>
<tr><th>$Sock_Num
 
</th><td>Get selected socket numbers
<tr><td>[[$Sock_Recv]]</td>
<td>Receive string based on count
</td></tr>
</td></tr>
<tr><th>$Sock_OnReset
 
</th><td>Set label to handle <var>RESET</var> conditions
<tr><td>[[$Sock_RecvPrs]]</td>
<td>Receive parsed string
</td></tr>
</td></tr>
<tr><th>$Sock_Recv
 
</th><td>Receive string based on count
<tr><td>[[$Sock_Send]]</td>
<td>Send string
</td></tr>
</td></tr>
<tr><th>$Sock_RecvPrs
 
</th><td>Receive parsed string
<tr><td>[[$Sock_SendLn]]</td>
<td>Send string followed by <var>LINEND</var>
</td></tr>
</td></tr>
<tr><th>$Sock_Send
 
</th><td>Send string
<tr><td>[[$Sock_Set]]</td>
<td>Change parameter or setting on one or all sockets
</td></tr>
</td></tr>
<tr><th>$Sock_SendLn
 
</th><td>Send string followed by <var>LINEND</var>
<tr><td>[[$Sock_SSL_On]]</td>
<td>Switch to SSL processing on a socket
</td></tr>
</td></tr>
<tr><th>$Sock_Set
 
</th><td>Change parameter or setting on one or all sockets
<tr><td>[[$Sock_Tran_In]]</td>
<td>Translate string, from character set of remote, to local internal character set ("EBCDIC")
</td></tr>
</td></tr>
<tr><th>$Sock_SSL_On
 
</th><td>Switch to SSL processing on a socket
<tr><td>[[$Sock_Tran_Out]]</td>
<td>Translate string, from local internal character set ("EBCDIC"), to character set of remote
</td></tr>
</td></tr>
<tr><th>$Sock_Tran_In
 
</th><td>Translate string, from character set of remote, to local internal character set ("EBCDIC")
<tr><td>[[$Sock_URL_Encode]]</td>
<td>Encode special characters into the URL "% hex hex" format
</td></tr>
</td></tr>
<tr><th>$Sock_Tran_Out
 
</th><td>Translate string, from local internal character set ("EBCDIC"), to character set of remote
<tr><td>Print operations</td>
</td></tr>
<td>In addition to the above list of $functions, data may be sent over a socket as the result of a "print" operation. This is accomplished by the <var>$Sock_Capture</var> function. Note that print operations outside a <var class="product">User Language</var> request can be captured as well, if a capturing socket has the <var>NOCLOSE</var> setting.
<tr><th>$Sock_URL_Encode
</th><td>Encode special characters into the URL "% hex hex" format
</td></tr>
<tr><th>Print operations
</th><td>In addition to the above list of $functions, data may be sent over a socket as the result of a "print" operation. This is accomplished by the <var>[[$Sock_Capture]]</var> function. Note that print operations outside a <var class="product">User Language</var> request can be captured as well, if a capturing socket has the <var>NOCLOSE</var> setting.
   
   
For example, the <var>DISPLAY</var> command, and the <var class="product">User Language</var> <var>Print</var> statement and <var>[[Text and Html statements|Html]]</var> statement block are all print operations;
For example, the <var>DISPLAY</var> command, and the <var class="product">User Language</var> <var>Print</var> statement and <var>[[Text and Html statements|Html]]</var> statement block are all print operations;
if they are invoked while print is captured to one or more sockets, their output lines are sent to the sockets.
if they are invoked while print is captured to one or more sockets, their output lines are sent to the sockets.
A print line is sent followed by the socket's current <var>[[LINEND (JANUS DEFINE parameter)|LINEND]]</var> value, if any. See [[$Sock_Capture#Print capturing hierarchy and other considerations|"Print capturing hierarchy and other considerations"]] and
A print line is sent followed by the socket's current <var>[[LINEND (JANUS DEFINE parameter)|LINEND]]</var> value, if any. See [[$Sock_Capture#Print capturing hierarchy and other considerations|Print capturing hierarchy and other considerations]] and
[[Sample Janus Sockets programs#Print capturing example|"Print capturing example"]].
[[Sample Janus Sockets programs#Print capturing example|Print capturing example]].
</td></tr></table>
</td></tr>
</table>
 
==CALLing Sirius $functions==
You can invoke many of the Sirius $functions
using a <var class="product">SOUL</var> <var>Call</var> statement instead of assigning the function
result to a %variable.
For example:
<p class="code">%l = $ListNew
$ListAdd(%L, 'Once upon a midnight dreary')
$ListAdd(%L, 'As I pondered weak and weary')
Call $List_Print(%l)
</p>
You can <var>Call</var> such $functions and still test for their return code, if necessary.
For example:
<p class="code">Call $List_Print(%l)
  If $List_Print(%l) Then
</p>
This "callability" is an optional approach; it does not replace %variable
assignment.
The callable $functions are indicated as such in their individual function
descriptions.
Typically they are $functions that do more than simply return a value,
and the value they return is primarily
an indicator of whether the function completed successfully.
<var>[[$ListCnt]]</var>, for example, is a (non-callable) $function that just returns a value.
 
==See also==
<ul>
<li>[[Janus Sockets User Language coding considerations]]
<li>[[Sample Janus Sockets programs]]
<li>Socket-level interfaces:
<ul>
<li>[[Janus Sockets $functions|$functions]]
<li>[[Socket class]]
</ul>
<li>Higher-level interfaces:
<ul>
<li>[[Email class]]
<li>[[HTTP Helper|HTTP Helper classes]]
<li>[[LDAP class]]
<li>[[Janus FTP Server]]
<li>[[Janus Telnet Server]]
</ul>


[[Category:Janus Sockets]]
[[Category:Janus Sockets]]

Latest revision as of 19:45, 1 August 2014

The User Language sockets API is implemented as the Janus Sockets $function set. The Janus SOAP Socket, HTTP Helper, Email, and LDAP objects and methods are alternatives that generalize the Janus Sockets $functions and are designed to be easier to use. These $functions and object methods provide User Language programs with the ability to receive and send using socket ports.

This topic is primarily concerned with how to use the individual $functions, though much of its text applies as well to the Socket object methods that are largely analogous to the $functions.

There are a few restrictions on the order in which the Janus Sockets $functions are used: for example, a socket port must be connected before data is sent using it, and data may not be sent after the FIN indicator is sent. For more information about Janus Sockets programming, see Janus Sockets User Language coding considerations.

Sample programs using $functions are included in Sample Janus Sockets programs and in the JANUS file distributed with this product.

Janus Sockets $function summary

The Janus Sockets SOUL $functions for communicating with remote hosts over TCP/IP are listed below and described individually in sections that follow:

$Sock_Capture Change print capture setting
$Sock_Cert_Info Get value of entity in partner's certificate
$Sock_Cert_Levels Get number of levels in partner's certificate
$Sock_Close Terminate sending and receiving of data on, and remove from use, one or all Janus Sockets connection(s)
$Sock_Conn Create connection to remote host using CLSOCK port
$Sock_ErrInfo Get info about last Janus Sockets error
$Sock_Info Get info about socket
$Sock_Num Get selected socket numbers
$Sock_OnReset Set label to handle RESET conditions
$Sock_Recv Receive string based on count
$Sock_RecvPrs Receive parsed string
$Sock_Send Send string
$Sock_SendLn Send string followed by LINEND
$Sock_Set Change parameter or setting on one or all sockets
$Sock_SSL_On Switch to SSL processing on a socket
$Sock_Tran_In Translate string, from character set of remote, to local internal character set ("EBCDIC")
$Sock_Tran_Out Translate string, from local internal character set ("EBCDIC"), to character set of remote
$Sock_URL_Encode Encode special characters into the URL "% hex hex" format
Print operations In addition to the above list of $functions, data may be sent over a socket as the result of a "print" operation. This is accomplished by the $Sock_Capture function. Note that print operations outside a User Language request can be captured as well, if a capturing socket has the NOCLOSE setting.

For example, the DISPLAY command, and the User Language Print statement and Html statement block are all print operations; if they are invoked while print is captured to one or more sockets, their output lines are sent to the sockets. A print line is sent followed by the socket's current LINEND value, if any. See Print capturing hierarchy and other considerations and Print capturing example.

CALLing Sirius $functions

You can invoke many of the Sirius $functions using a SOUL Call statement instead of assigning the function result to a %variable. For example:

%l = $ListNew $ListAdd(%L, 'Once upon a midnight dreary') $ListAdd(%L, 'As I pondered weak and weary') Call $List_Print(%l)

You can Call such $functions and still test for their return code, if necessary. For example:

Call $List_Print(%l) If $List_Print(%l) Then

This "callability" is an optional approach; it does not replace %variable assignment.

The callable $functions are indicated as such in their individual function descriptions. Typically they are $functions that do more than simply return a value, and the value they return is primarily an indicator of whether the function completed successfully. $ListCnt, for example, is a (non-callable) $function that just returns a value.

See also