[Home] [Downloads] [Search] [Help/forum]

MUSHclient scripting

Description of MUSHclient world function: world.GetUdpPort


Name GetUdpPort
Type Method
Summary Find a free port for UDP listening
Prototype long GetUdpPort(long First, long Last);

View list of data type meanings

Description

This function finds a free port for use by MUSHclient as a UDP listener. It operates by scanning all open worlds for ports in use by UdpListen. It then works through the range you specify to find one that is not in use.

However this test is only for port used by MUSHclient. There is no guarantee that the port is not in use by another application.

The intention is for plugin writers to use it to find a port in a range (say, 4000 to 4100) which is not in use by another plugin, or the same plugin in another world.

The First and Last arguments are port numbers, inclusive, that you wish to be scanned. eg. GetUdpPort (4000, 4100) would find a port in the range 4000 to 4100 inclusive.

The port numbers must be greater than zero and less than 65535. Also the last port number must be greater than or equal to the first port number.


Note: Available in version 3.66 onwards.


VBscript example
Note GetUdpPort (4000, 4100)
Jscript example
Note (GetUdpPort (4000, 4100))
Lua example
free_port = GetUdpPort (4000, 4100)
Returns 0 : No free port was found in the specified range, or the range was invalid.

non-zero : A port not in use by MUSHclient's UdpListen function.
Introduced in version 3.66

See also ...

Function Description
UdpListen Listens for incoming packets using the UDP protocol
UdpPortList Returns an array of all the UDP ports in use by this world
UdpSend Sends a packet over the network using the UDP protocol

Search for script function

Enter a word or phrase in the box below to narrow the list down to those that match.

The function name, prototype, summary, and description are searched.

Search for:   

Leave blank to show all functions.


Return codes

Many functions return a "code" which indicates the success or otherwise of the function.

You can view a list of the return codes


Function prototypes

The "prototype" part of each function description lists exactly how the function is called (what arguments, if any, to pass to it).

You can view a list of the data types used in function prototypes


View all functions

[Back]

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]