Packages

object UDPDatagramSocket

Companion object for the UDPDatagramSocket trait, containing methods to simplify creation of UDPDatagramSocket objects, as well as some useful utility methods. See the documentation for the UDPDatagramSocket trait for a full treatment on this API.

See also

UDPDatagramSocket

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. UDPDatagramSocket
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. def apply(): UDPDatagramSocket

    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.

    returns

    the UDPDatagramSocket object

  2. def apply(port: Int): UDPDatagramSocket

    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.

    port

    the local port

    returns

    the UDPDatagramSocket object

  3. def apply(address: IPAddress, port: Int): UDPDatagramSocket

    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.

    address

    the local IP address

    port

    the local port

    returns

    the UDPDatagramSocket object

  4. def send(bytes: Seq[Byte], address: IPAddress, port: Int, broadcast: Boolean): Unit

    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()
    bytes

    sequence of bytes to send

    address

    IP address to which to send bytes

    port

    UDP port to which to send bytes

    broadcast

    whether or not to enable broadcast on the socket

  5. def send(bytes: Seq[Byte], address: IPAddress, port: Int): Unit

    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()
    bytes

    sequence of bytes to send

    address

    IP address to which to send bytes

    port

    UDP port to which to send bytes

  6. def sendString(data: String, encoding: String, address: IPAddress, port: Int, broadcast: Boolean): Unit

    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()
    data

    String data to send

    encoding

    Encoding to use

    address

    IP address to which to send bytes

    port

    UDP port to which to send bytes

    broadcast

    Whether to enable broadcast or not.

  7. def sendString(data: String, address: IPAddress, port: Int, broadcast: Boolean): Unit

    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()
    data

    String data to send

    address

    IP address to which to send bytes

    port

    UDP port to which to send bytes

    broadcast

    Whether to enable broadcast or not.

  8. def sendString(data: String, address: IPAddress, port: Int): Unit

    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()
    data

    String data to send

    address

    IP address to which to send bytes

    port

    UDP port to which to send bytes

  9. def sendString(data: String, encoding: String, address: IPAddress, port: Int): Unit

    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()
    data

    String data to send

    encoding

    Encoding to use

    address

    IP address to which to send bytes

    port

    UDP port to which to send bytes