Start from base library version 2.7.0. Please remaining backward compatible.
One UDP Socket Instance, by default IPv4 Protocol.
Bind a system randomly assigned available port or bind a specified port number
Set up IP_TTL Socket option to set a IP Maximum number of hops allowed for packet transmission
To the specified IP and port Send a message. Base library 2.9.0 Support Broadcast (The specified address is 255.255.255.255)。
Preconnect to the specified IP and Port, you need to cooperate. write Methods used together
Usage and send Method is the same if the connect With send No difference (note that even if the connect You also need to fill in the address and port parameters for this interface.
Stop UDP Socket Instance, equivalent to destruction. After the shutdown, UDP Socket Instance can no longer send messages, and each time the
UDPSocket.send Will trigger an error event, and message The event callback function also does not execute again. in
UDPSocket Instance will be created by the Native Strong references, ensuring that they are not GC。 in
UDPSocket.close Removes a strong reference to it, and lets the UDPSocket Instance compliance GC。
Listen Close Event
Unlisten Close Event
Listen for error events
Unlisten Error Event
Listen to start listening for packet messages
The event that starts listening for packet messages
Listen to events that receive messages
Unlisten for events that receive messages
|Error code||Error message||Introductions|
|-2||Socket interface error|
|-3||Send failed, no interface permissions|
|1||Send failed, parameter error, address illegal|
|2||Send failed, parameter error, port illegal|