Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.teleal.cling.transport.spi
Interface DatagramIO<C extends DatagramIOConfiguration>

Type Parameters:
  `C` - The type of the service's configuration.

All Superinterfaces:
  Runnable

All Known Implementing Classes:
  DatagramIOImpl

    public interface DatagramIO<C extends DatagramIOConfiguration>

extends Runnable

Service for receiving (unicast only) and sending UDP datagrams, one per bound IP address.

This service typically listens on a socket for UDP unicast datagrams, with an ephemeral port.

This listening loop is started with the `run()` method, this service is `Runnable`. Any received datagram is then converted into an `IncomingDatagramMessage` and handled by the `Router.received(org.teleal.cling.model.message.IncomingDatagramMessage)` method. This conversion is the job of the `DatagramProcessor`.

Clients of this service use it to send UDP datagrams, either to a unicast or multicast destination. Any `OutgoingDatagramMessage` can be converted and written into a datagram with the `DatagramProcessor`.

An implementation has to be thread-safe.

Author:
  Christian Bauer

Method Summary
`C` | `getConfiguration()`
`void` | `init(InetAddress bindAddress, Router router, DatagramProcessor datagramProcessor)` Configures the service and starts any listening sockets.
`void` | `send(DatagramPacket datagram)` The actual sending of a UDP datagram.
`void` | `send(OutgoingDatagramMessage message)` Sends a datagram after conversion with `DatagramProcessor.write(org.teleal.cling.model.message.OutgoingDatagramMessage)`.
`void` | `stop()` Stops the service, closes any listening sockets.

Methods inherited from interface java.lang.Runnable
`run`

Method Detail

### init

    void init(InetAddress bindAddress,
              Router router,
              DatagramProcessor datagramProcessor)
              throws InitializationException

  Configures the service and starts any listening sockets.

  Parameters:
    `bindAddress` - The address to bind any sockets on.
    `router` - The router which handles received `IncomingDatagramMessage`s.
    `datagramProcessor` - Reads and writes datagrams.
  Throws:
    `InitializationException` - If the service could not be initialized or started.

### stop

    void stop()

  Stops the service, closes any listening sockets.

### getConfiguration

    C getConfiguration()

  Returns:
    This service's configuration.

### send

    void send(OutgoingDatagramMessage message)

  Sends a datagram after conversion with `DatagramProcessor.write(org.teleal.cling.model.message.OutgoingDatagramMessage)`.

  Parameters:
    `message` - The message to send.

### send

    void send(DatagramPacket datagram)

  The actual sending of a UDP datagram.

  Recoverable errors should be logged, if appropriate only with debug level. Any non-recoverable errors should be thrown as `RuntimeException`s.

  Parameters:
    `datagram` - The UDP datagram to send.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010 Teleal GmbH, Switzerland. All Rights Reserved.