Create a UDP datagram socket object that's bound to any available local port and the wildcard IP address.
Create a UDP datagram socket object that's bound to any available local port and the wildcard IP address. The broadcast flag will initially be clear.
the UDPDatagramSocket
object
Create a UDP datagram socket object that's bound to the specified local port and the wildcard IP address.
Create a UDP datagram socket object that's bound to the specified local port and the wildcard IP address. The broadcast flag will initially be clear.
the local port
the UDPDatagramSocket
object
Create a UDP datagram socket object that's bound to the specified local port and IP address.
Create a UDP datagram socket object that's bound to the specified local port and IP address. The broadcast flag will initially be clear.
the local IP address
the local port
the UDPDatagramSocket
object
Utility method for sending a UDP packet.
Utility method for sending a UDP packet. This method is equivalent to the following code snippet:
// Bind to a local (source) UDP port. val socket = UDPDatagramSocket() val address = IPAddress( /* details omitted */) val port: Int = ... val broadcast: Boolean = ... // Set (or clear) the broadcast flag. socket.broadcast = broadcast // Send the bytes to the specified destination address and UDP port. socket.send(bytes, address, port) // Close the socket socket.close()
sequence of bytes to send
IP address to which to send bytes
UDP port to which to send bytes
whether or not to enable broadcast on the socket
Utility method for sending a non-broadcast UDP packet.
Utility method for sending a non-broadcast UDP packet. This method is equivalent to the following code snippet:
// Bind to a local (source) UDP port. val socket = UDPDatagramSocket.bind() val address = IPAddress( /* details omitted */) val port: Int = ... // Send the bytes to the specified destination address and UDP port. socket.send(bytes, address, port) // Close the socket socket.close()
sequence of bytes to send
IP address to which to send bytes
UDP port to which to send bytes
Utility method for sending a UDP packet consisting string data.
Utility method for sending a UDP packet consisting string data. The string data is encoded the specified encoding before being sent. This method is equivalent to the following code snippet:
// Bind to a local (source) UDP port. val socket = UDPDatagramSocket() val address = IPAddress( /* details omitted */) val port: Int = ... val encoding: String = ... val broadcast: Boolean = ... // Set (or clear) the broadcast flag. socket.broadcast = broadcast // Send the string to the specified destination address and UDP port. socket.send(string, encoding, address, port) // Close the socket socket.close()
String data to send
Encoding to use
IP address to which to send bytes
UDP port to which to send bytes
Whether to enable broadcast or not.
Utility method for sending a UDP packet consisting string data.
Utility method for sending a UDP packet consisting string data. The string data is encoded in UTF-8 before being sent. This method is equivalent to the following code snippet:
// Bind to a local (source) UDP port. val socket = UDPDatagramSocket() val address = IPAddress( /* details omitted */) val port: Int = ... val broadcast: Boolean = ... // Set (or clear) the broadcast flag. socket.broadcast = broadcast // Send the string to the specified destination address and UDP port. socket.send(string, address, port) // Close the socket socket.close()
String data to send
IP address to which to send bytes
UDP port to which to send bytes
Whether to enable broadcast or not.
Utility method for sending a non-broadcast UDP packet consisting of string data.
Utility method for sending a non-broadcast UDP packet consisting of string data. The string data is encoded in UTF-8 before being sent. This method is equivalent to the following code snippet:
// Bind to a local (source) UDP port. val socket = UDPDatagramSocket.bind() val address = IPAddress( /* details omitted */) val port: Int = ... // Send the string to the specified destination address and UDP port. socket.send(string, address, port) // Close the socket socket.close()
String data to send
IP address to which to send bytes
UDP port to which to send bytes
Utility method for sending a non-broadcast UDP packet consisting of string data.
Utility method for sending a non-broadcast UDP packet consisting of string data. The string data is encoded the specified encoding before being sent. This method is equivalent to the following code snippet:
// Bind to a local (source) UDP port. val socket = UDPDatagramSocket.bind() val address = IPAddress( /* details omitted */) val port: Int = ... val encoding: String = ... // Send the string to the specified destination address and UDP port. socket.send(string, encoding, address, port) // Close the socket socket.close()
String data to send
Encoding to use
IP address to which to send bytes
UDP port to which to send bytes
Companion object for the
UDPDatagramSocket
trait, containing methods to simplify creation ofUDPDatagramSocket
objects, as well as some useful utility methods. See the documentation for theUDPDatagramSocket
trait for a full treatment on this API.UDPDatagramSocket