GetSocketObject (Socket function): Difference between revisions
Jump to navigation
Jump to search
m (→Syntax terms) |
mNo edit summary |
||
Line 1: | Line 1: | ||
{{Template:Socket:GetSocketObject subtitle}} | |||
This [[Notation conventions for methods#Shared members|shared]] | This [[Notation conventions for methods#Shared members|shared]] | ||
Line 10: | Line 5: | ||
It returns a reference to an instance of a | It returns a reference to an instance of a | ||
<var>Socket</var> object, which can then be used with instance method calls. | <var>Socket</var> object, which can then be used with instance method calls. | ||
==Syntax== | ==Syntax== | ||
{{Template:Socket:GetSocketObject syntax}} | |||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
Line 63: | Line 59: | ||
<p class="code">The %sockhrb status is: CONN | <p class="code">The %sockhrb status is: CONN | ||
</p> | </p> | ||
{{Template:Socket:GetSocketObject footer}} |
Revision as of 23:06, 14 November 2011
Get a socket object for the given socket number (Socket class)
This shared
method returns a Socket object for a given socket number.
It returns a reference to an instance of a
Socket object, which can then be used with instance method calls.
Syntax
%socket = [%(Socket):]GetSocketObject( number)
Syntax terms
%so | A declared socket object or a reference to a Socket object. |
---|---|
%(Socket) | The class name in parentheses denotes a shared method. Specifying %(Socket): is not the only way to invoke the method (see ?? refid=themeth.).
|
socketnum | The number of a socket that was created with $Sock_Conn. |
Usage notes
- GetSocketObject is designed for adding Socket object code to an existing $Sock_xxx application, that is, for instantiating a socket from a socket number returned from $Sock_Conn. If you are building an entirely object-oriented socket application, use the New constructor.
- After GetSocketObject returns, the socket is no longer accessible by its socket number. To access the socket by its number again, use GetSocketNumber.
- If the object returned by a GetSocketObject invocation is the method object
for a subsequent GetSocketNumber invocation, the
NOCLOSE
setting of the original numbered socket is applied to the numbered socket returned by GetSocketNumber. For information about NOCLOSE, see Set.
Example
In the following example,a socket created with $Sock_Conn is converted to a Socket object.
JANUS DEFINE PIPE * CLSOCK 8 REMOTE * * SOCKPMAX 10 JANUS START PIPE Begin %nums Is String Len 16 %sockhrb object Socket %CONN is float %CONN = $SOCK_CONN('PIPE', 'www.whrb.org', 80) %nums = %(Socket):Num('OPEN') %sockhrb = %(Socket):GetSocketObject(%nums) Print 'The %sockhrb status is: ' %sockhrb:Info('STAT') End
The example result is:
The %sockhrb status is: CONN