$Sock_Num

From m204wiki
Jump to navigation Jump to search

Get selected socket numbers

Note: Many $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for $Sock_Num is the Num method.

$Sock_Num retrieves selected socket numbers.

Syntax

%nums = $Sock_Num[([selection])]

Syntax terms

%nums A string that contains blank-separated selected socket numbers in ascending order.
selection A string that identifies which socket numbers to return. It is any combination of the following strings separated by OR, and each optionally prefixed by NOT:
ANY Return all sockets. This is the default.
CONN Return sockets enabled for sending in both directions.
FINR Return sockets on which local partner is enabled for sending but remote has stopped sending ("FIN received").
FINS Return sockets on which remote partner is enabled for sending but local stopped sending ("FIN sent").
FINBOTH Return OPEN sockets on which remote and local partners both stopped sending ("FIN sent and received").
RESET Return in-use but no longer connected sockets.
OPEN Return OPEN sockets. This is equivalent to either of the following:
  • NOT RESET
  • CONN OR FINR OR FINS OR FINBOTH
CAPTURE Return sockets (OPEN or not) for which print capturing is on.
CAPOPEN Return OPEN sockets for which print capturing is on.

If NOT prefixes one of the above specifications, then all in-use sockets (excluding the specified set) are included in the selected set. With multiple terms separated by OR, the specified sets are combined by the set union operation.

Usage notes

$Sock_Num does not have a socket number argument, and thus it is not affected by any ONRESET setting.

Examples

  1. In the following example, %sock contains the blank-delimited values of %c1 and %c2. Assuming no other client socket numbers were in use, this would result in %sock = '2 3'.

    JANUS DEFINE PIPE * CLSOCK 5 REMOTE * * SOCKPMAX 2 Begin %c1 is Float %c2 is Float %sock is String Len 255 %c1 = $Sock_conn('PIPE', 'www.ampas.org', 80) %c2 = $Sock_conn('PIPE', 'www.wga.org', 80) %sock = $Sock_Num ...

  2. The following example shows another way to retrieve the list of all OPEN socket numbers:

    %sock = $Sock_Num('NOT RESET')

  3. The following example shows how to retrieve the list of all OPEN socket numbers that have not received the FIN indicator:

    %sock = $Sock_Num('CONN OR FINS')