ServerSocket (Socket function): Difference between revisions
m (→Syntax terms) |
mNo edit summary |
||
Line 1: | Line 1: | ||
{{Template:Socket:ServerSocket subtitle}} | |||
This [[Notation conventions for methods#Shared members|shared]] method obtains a reference to a | This [[Notation conventions for methods#Shared members|shared]] method obtains a reference to a | ||
Line 14: | Line 9: | ||
==ServerSocket syntax== | ==ServerSocket syntax== | ||
{{Template:Socket:ServerSocket syntax}} | |||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
Line 23: | Line 18: | ||
<tr><th><var>%(Socket)</var></th> | <tr><th><var>%(Socket)</var></th> | ||
<td>The class name in parentheses denotes a shared method. Specifying <code>%(Socket):</code> is not the only way to invoke the method (see [[??]] refid=themeth.). | <td>The class name in parentheses denotes a shared method. Specifying <code>%(Socket):</code> is not the only way to invoke the method (see [[??]] refid=themeth.). | ||
</td></tr></table> | </td></tr></table> | ||
Line 55: | Line 49: | ||
... | ... | ||
</p> | </p> | ||
{{Template:Socket:ServerSocket footer}} |
Revision as of 23:16, 14 November 2011
Get a reference to the server socket (Socket class)
This shared method obtains a reference to a
Socket object for the server socket (socket number 1 in the $Sock_xxx API,
as described in "Client versus Server Socket programming".
It returns a reference to a Socket object instance, which can then be
used with instance method calls to access the server socket.
ServerSocket has no equivalent $function.
ServerSocket syntax
%socket = [%(Socket):]ServerSocket
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.).
|
Usage notes
- After ServerSocket returns, the socket is no longer accessible by its socket number (1). To access the socket by its number again, use GetSocketNumber.
- ServerSocket can be used to obtain a Socket object reference for a socket already created by $Sock_Conn, or it can operate in an entirely object-oriented application.
Example
In the following code fragment, a server socket receives data and replies to its client.
Begin %r Float %sepx Float %data is String len 255 %servsock is Object Socket %servsock = %(Socket):ServerSocket %r = %servsock:Set('PRSTOK', 'AMBIG|0D0A|0D|0A|07') %r = %servsock:Set('LINEND', '07') %r = %servsock:ReceiveAndParse(%data) If %r le 0 Then ... If %data eq 'Hello' Then ... %r = %servsock:SendWithLineEnd('OK') ...