net.i2p.i2ptunnel.udp

## Class UDPSink

- java.lang.Object
- - net.i2p.i2ptunnel.udp.UDPSink

- All Implemented Interfaces:
    Sink

      public class UDPSink
      extends Object
      implements Sink

  UDP sink implementation for streaming data.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected InetAddress` | `remoteHost`
    `protected int` | `remotePort`
    `protected DatagramSocket` | `sock`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `UDPSink(DatagramSocket socket, InetAddress host, int port)`
    `UDPSink(InetAddress host, int port)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getPort()`
    `DatagramSocket` | `getSocket()` Returns the underlying DatagramSocket for use by UDPSource constructor.
    `void` | `send(Destination src, int fromPort, int toPort, byte[] data)`
    `void` | `stop()` Closes the underlying DatagramSocket.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### remoteHost

          protected final InetAddress remoteHost

    - #### remotePort

          protected final int remotePort

    - #### sock

          protected final DatagramSocket sock

  - ### Constructor Detail

    - #### UDPSink

          public UDPSink(DatagramSocket socket,
                         InetAddress host,
                         int port)

      Parameters:
        `socket` - existing socket
        `host` - where to send
        `port` - where to send

    - #### UDPSink

          public UDPSink(InetAddress host,
                         int port)

      Parameters:
        `host` - where to send
        `port` - where to send
      Throws:
        `IllegalArgumentException` - on DatagramSocket IOException

  - ### Method Detail

    - #### getPort

          public int getPort()

      Returns:
        the local port of the DatagramSocket we are sending from

    - #### getSocket

          public DatagramSocket getSocket()

      Returns the underlying DatagramSocket for use by UDPSource constructor.
      Returns:
        the DatagramSocket

    - #### send

          public void send(Destination src,
                           int fromPort,
                           int toPort,
                           byte[] data)

      Specified by:
        `send` in interface `Sink`
      Parameters:
        `src` - ignored
        `fromPort` - ignored
        `toPort` - ignored
      Throws:
        `RuntimeException` - on DatagramSocket IOException

    - #### stop

          public void stop()

      Closes the underlying DatagramSocket.