Num (Socket function): Difference between revisions
m (→Syntax terms) |
m (typo) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Template:Socket:Num subtitle}} | |||
This [[Notation conventions for methods#Shared members|shared]] method retrieves the socket numbers | This [[Notation conventions for methods#Shared members|shared]] method retrieves the socket numbers | ||
Line 11: | Line 6: | ||
it implicitly executes a <var>[[GetSocketNumber (Socket function)|GetSocketNumber]]</var>. | it implicitly executes a <var>[[GetSocketNumber (Socket function)|GetSocketNumber]]</var>. | ||
The <var>Num</var> function has an effect similar to <var>[[$Sock_Num]]</var>. | The <var>Num</var> function has an effect similar to <var>[[$Sock_Num]]</var>. | ||
==Syntax== | ==Syntax== | ||
{{Template:Socket:Num syntax}} | |||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>% | <tr><th>%string</th> | ||
<td>Return string, which is to contain blank-separated socket numbers. | <td>Return string, which is to contain blank-separated socket numbers. | ||
</td></tr> | </td></tr> | ||
<tr><th><var>%(Socket)</var></th> | <tr><th><var class="nobr">%(Socket)</var></th> | ||
<td>The class name in parentheses denotes a shared method. | <td>The class name in parentheses denotes a shared method. <var>Num</var> can also be invoked via a <var>Socket</var> object variable, which may be <var>Null</var>.</td></tr> | ||
</td></tr> | <tr><th>string</th> | ||
<tr><th> | |||
<td>The socket numbers to return: any combination of the following strings separated by <code>OR</code>, and each optionally prefixed by <code>NOT</code>: <table class="syntaxTable"> <tr><th><var>ANY</var> </th><td>Return all in-use sockets [default]. | <td>The socket numbers to return: any combination of the following strings separated by <code>OR</code>, and each optionally prefixed by <code>NOT</code>: <table class="syntaxTable"> <tr><th><var>ANY</var> </th><td>Return all in-use sockets [default]. | ||
</td></tr> | </td></tr> |
Latest revision as of 16:07, 26 January 2018
Socket numbers of a set of selected sockets (Socket class)
This shared method retrieves the socket numbers
of the set of sockets you select.
For Socket objects,
it implicitly executes a GetSocketNumber.
The Num function has an effect similar to $Sock_Num.
Syntax
%string = %(Socket):Num[( [string])]
Syntax terms
%string | Return string, which is to contain blank-separated socket numbers. | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
%(Socket) | The class name in parentheses denotes a shared method. Num can also be invoked via a Socket object variable, which may be Null. | ||||||||||||||||||
string | The socket numbers to return: any combination of the following strings separated by OR , and each optionally prefixed by NOT :
If |
Usage notes
- The Num method returns a blank-delimited string containing the numbers of the requested sockets in ascending order.
- The Num method is not affected by any ONRESET setting.
Examples
- In the following example,
%nums
contains the blank-delimited numbers of (all) the open sockets:JANUS DEFINE PIPE * CLSOCK 5 REMOTE * * SOCKPMAX 2 JANUS START PIPE Begin %nums Is String Len 255 %sockamp object Socket %sockwga object Socket %sockamp = New('PIPE', 'www.ampas.org', 80) If %sockamp Is Null Then Print 'Error:' And $STATUSD Stop End If %sockwga = New('PIPE', 'www.wga.org', 80) If %sockwga Is Null Then Print 'Error:' And $STATUSD Stop End If %nums = %(Socket):Num Print 'The socket numbers are: ' %nums %sockamp:Close %sockwga:Close End
The example result is:
The socket numbers are: 2 3
- The following example shows another way to retrieve the list of all OPEN socket numbers:
%nums = %(Socket):Num('NOT RESET')
- The following example shows how to retrieve the list of all OPEN
socket numbers that have not received the FIN indicator:
%nums = %(Socket):Num('CONN OR FINS')