New (UdpSocket constructor): Difference between revisions
Jump to navigation
Jump to search
m (→Syntax terms) |
m (→Usage notes) |
||
Line 22: | Line 22: | ||
==Usage notes== | ==Usage notes== | ||
<ul> | |||
<li>While the New method doesn't attempt to communicate with a target host, it can fail with a request canceling error if no CLSOCKU port is available or the maximum number of connections for a port is exceeded.</li> | |||
<li>While a UDP socket doesn't actually have a connection with anything, a New method uses a logical connection for the port until the UdpSocket object is discarded. his logical connection is counted against the ports maximum connection limit.</li> | |||
</ul> | |||
==Examples== | ==Examples== | ||
==See also== | ==See also== | ||
{{Template:UdpSocket:New footer}} | {{Template:UdpSocket:New footer}} |
Revision as of 17:26, 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
%outUdpSocket | udpSocket |
---|---|
[%(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 messages 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
- While the New method doesn't attempt to communicate with a target host, it can fail with a request canceling error if no CLSOCKU port is available or the maximum number of connections for a port is exceeded.
- While a UDP socket doesn't actually have a connection with anything, a New method uses a logical connection for the port until the UdpSocket object is discarded. his logical connection is counted against the ports maximum connection limit.