GetUdpPort
Script function

world.GetUdpPort

DOC_scripting Read about scripting

Type

Method

Summary

Find a free port for UDP listening

Prototype

long GetUdpPort(long First, long Last);

DOC_data_types 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.



VBscript example

Note GetUdpPort (4000, 4100)



Jscript example

Note (GetUdpPort (4000, 4100))



Lua example

free_port = GetUdpPort (4000, 4100)



Return value

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.




See Also ...

Functions

FNC_UdpListen UdpListen (Listens for incoming packets using the UDP protocol)
FNC_UdpPortList UdpPortList (Returns an array of all the UDP ports in use by this world)
FNC_UdpSend UdpSend (Sends a packet over the network using the UDP protocol)

(Help topic: function=GetUdpPort)

DOC_contents Documentation contents page