# UDPSocket
Start from base library version 2.7.0. Please remaining backward compatible.
An UDP Socket instance. Use IPv4 protocol by default.
# Methods
# number UDPSocket.bind()
Binds an available port randomly assigned by the system.
# UDPSocket.send(Object object)
Sends messages to the specified IP and port.
# UDPSocket.close()
Closes (Terminates) a UDP Socket instance. After closing, the UDP Socket instance can no longer send messages. Calling UDPSocket.send
will trigger an error event, and the callback function for the message event will not be executed. After the UDPSocket
instance is created, it will be strongly referenced by Native to ensure that it is not collected by GC. After calling UDPSocket.close
, the strong reference to it will be removed, and the UDPSocket instance will follow the GC rules.
# UDPSocket.onClose(function callback)
Listens on the disabling event.
# UDPSocket.offClose(function callback)
Un-listens on the disabling event.
# UDPSocket.onError(function callback)
Listens on the error event.
# UDPSocket.offError(function callback)
Un-listens on the error event.
# UDPSocket.onListening(function callback)
Listens on the event of starting listening on data packet messages.
# UDPSocket.offListening(function callback)
Un-listens on the event of starting listening on data packet messages.
# UDPSocket.onMessage(function callback)
Listens on the event of receiving messages.
# UDPSocket.offMessage(function callback)
Un-listens on the event of receiving messages.