New (UdpSocket constructor): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 10: Line 10:
<td>The optional class name in parentheses denotes a <var>[[Notation conventions for methods#Constructors|Constructor]]</var>. See [[#Usage notes|"Usage notes"]], below, for more information about invoking a <var>Constructor</var>.</td></tr>
<td>The optional class name in parentheses denotes a <var>[[Notation conventions for methods#Constructors|Constructor]]</var>. See [[#Usage notes|"Usage notes"]], below, for more information about invoking a <var>Constructor</var>.</td></tr>
<tr><th><var>ClientPort</var></th>
<tr><th><var>ClientPort</var></th>
<td>string</td></tr>
<td>The name of the client UDP socket (CLSOCKU) port. The default is the <var>[[MASTER]]</var> CLSOCKU port, if any is defined. However, if you omit <var class="term">clientport</var> and no <var>MASTER</var> CLSOCKU port is defined, the request is canceled.</td></tr>
<tr><th><var>LocalHost</var></th>
<tr><th><var>LocalHost</var></th>
<td>string</td></tr>
<td>The IP address to use for messages sent on the client socket port. If not specified, the default or only IP address of the host on which Model 204 is running is used. This parameter is an alternative to the [[BINDADDR (JANUS DEFINE parameter)|BINDADDR JANUS DEFINE parameter]]. If <var>BINDADDR</var> is specified on the CLSOCKU port used for the UdpSocket, the <var>LocalHost</var> parameter is unnecessary and, if specified, must match the IP address specified on the <var>BINDADDR</var>. If <var>LocalHost</var> or <var>BINDADDR</var> is specified for a UDP socket, only messaged sent to that IP address will be received by the UdpSocket object.</td></tr>
<tr><th><var>LocalPort</var></th>
<tr><th><var>LocalPort</var></th>
<td>number</td></tr>
<td>The UDP port number to use for messages sent to and received from the UdpSocket. If this parameter is not specified, the UDP stack will assign a port number (usually 1024 and higher) to the UdpSocket object. This parameter is most useful when writing a UDP server application that is handled by a single thread (since only one thread can issue a New for a particular UDP port number). Typically a server application will create a UdpSocket for a well-known UDP port number to which clients subsequently send requests. There are some protocols such as SNMP that sometimes send messages from a well-known port number to another server.</td></tr>
<tr><th><var>Host</var></th>
<tr><th><var>Host</var></th>
<td>string</td></tr>
<td>The target host for messages sent from the UDP socket. This can be an IP address or a host name, the latter being resolved using the [[JANUS NAMESERVER|Janus Domain Name Services support]]. If <var>Host</var> is specified on the <var>New</var> method invocation, it cannot be changed later. If an application wishes to use a UdpSocket to communicate with multiple hosts, it should not specify <var>Host</var> on the New method invocation.</td></tr>
<tr><th><var>Port</var></th>
<tr><th><var>Port</var></th>
<td>number</td></tr>
<td>The target port number for messages sent from the UDP port. This must be a number between 1 and 65534. If <var>Port</var> is specified on the <var>New</var> method invocation, it cannot be changed later. If an application wishes to use a UdpSocket to communicate with multiple port numbers, it should not specify <var>Port</var> on the New method invocation.</td></tr>
</table>
</table>
==Usage notes==
==Usage notes==

Revision as of 17:15, 22 April 2012

Create a UdpSocket object (UdpSocket class)

[Introduced in Sirius Mods 8.0]


New creates an instance of a UdpSocket object. This object can be used to exchange messages with a remote host using a Janus client socket (CLSOCKU) port.

Syntax

%udpSocket = [%(UdpSocket):]New[( [ClientPort= string], [LocalHost= string], - [LocalPort= number], [Host= string], - [Port= number])]

Syntax terms

%outUdpSocketudpSocket
[%(UdpSocket):] The optional class name in parentheses denotes a Constructor. See "Usage notes", below, for more information about invoking a Constructor.
ClientPort The name of the client UDP socket (CLSOCKU) port. The default is the MASTER CLSOCKU port, if any is defined. However, if you omit clientport and no MASTER CLSOCKU port is defined, the request is canceled.
LocalHost The IP address to use for messages sent on the client socket port. If not specified, the default or only IP address of the host on which Model 204 is running is used. This parameter is an alternative to the BINDADDR JANUS DEFINE parameter. If BINDADDR is specified on the CLSOCKU port used for the UdpSocket, the LocalHost parameter is unnecessary and, if specified, must match the IP address specified on the BINDADDR. If LocalHost or BINDADDR is specified for a UDP socket, only messaged sent to that IP address will be received by the UdpSocket object.
LocalPort The UDP port number to use for messages sent to and received from the UdpSocket. If this parameter is not specified, the UDP stack will assign a port number (usually 1024 and higher) to the UdpSocket object. This parameter is most useful when writing a UDP server application that is handled by a single thread (since only one thread can issue a New for a particular UDP port number). Typically a server application will create a UdpSocket for a well-known UDP port number to which clients subsequently send requests. There are some protocols such as SNMP that sometimes send messages from a well-known port number to another server.
Host The target host for messages sent from the UDP socket. This can be an IP address or a host name, the latter being resolved using the Janus Domain Name Services support. If Host is specified on the New method invocation, it cannot be changed later. If an application wishes to use a UdpSocket to communicate with multiple hosts, it should not specify Host on the New method invocation.
Port The target port number for messages sent from the UDP port. This must be a number between 1 and 65534. If Port is specified on the New method invocation, it cannot be changed later. If an application wishes to use a UdpSocket to communicate with multiple port numbers, it should not specify Port on the New method invocation.

Usage notes

Examples

See also