net.i2p.router.transport.udp

## Class UDPEndpoint

- java.lang.Object
- - net.i2p.router.transport.udp.UDPEndpoint

- All Implemented Interfaces:
    SocketListener

      class UDPEndpoint
      extends Object
      implements SocketListener

  Coordinate the low-level datagram socket, creating and managing the UDPSender and UDPReceiver.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `UDPEndpoint(RouterContext ctx, UDPTransport transport, int listenPort, InetAddress bindAddress)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearOutbound()` Clear outbound queue, probably in preparation for sending destroy() to everybody.
    `void` | `fail()`
    `int` | `getListenPort()` call after startup() to get actual port or -1 on startup failure
    `UDPSender` | `getSender()`
    `boolean` | `isIPv4()`
    `boolean` | `isIPv6()`
    `UDPPacket` | `receive()` Blocking call to receive the next inbound UDP packet from any peer.
    `void` | `send(UDPPacket packet)` Add the packet to the outobund queue to be sent ASAP (as allowed by the bandwidth limiter) BLOCKING if queue is full.
    `void` | `setListenPort(int newPort)`
    `void` | `shutdown()`
    `void` | `startup()` Caller should call getListenPort() after this to get the actual bound port and determine success .
    `String` | `toString()`

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

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

- - ### Constructor Detail

    - #### UDPEndpoint

          public UDPEndpoint(RouterContext ctx,
                             UDPTransport transport,
                             int listenPort,
                             InetAddress bindAddress)

      Parameters:
        `transport` - may be null for unit testing ONLY
        `listenPort` - -1 or the requested port, may not be honored
        `bindAddress` - null ok

  - ### Method Detail

    - #### clearOutbound

          public void clearOutbound()

      Clear outbound queue, probably in preparation for sending destroy() to everybody.

    - #### fail

          public void fail()

      Specified by:
        `fail` in interface `SocketListener`

    - #### getListenPort

          public int getListenPort()

      call after startup() to get actual port or -1 on startup failure

    - #### getSender

          public UDPSender getSender()

    - #### isIPv4

          public boolean isIPv4()

      Returns:
        true for wildcard too

    - #### isIPv6

          public boolean isIPv6()

      Returns:
        true for wildcard too

    - #### receive

          public UDPPacket receive()

      Blocking call to receive the next inbound UDP packet from any peer. UNIT TESTING ONLY. Direct from the socket. In normal operation, UDPReceiver thread injects to PacketHandler queue.
      Returns:
        null if we have shut down, or on failure

    - #### send

          public void send(UDPPacket packet)

      Add the packet to the outobund queue to be sent ASAP (as allowed by the bandwidth limiter) BLOCKING if queue is full.

    - #### setListenPort

          public void setListenPort(int newPort)

    - #### shutdown

          public void shutdown()

    - #### startup

          public void startup()
                       throws SocketException

      Caller should call getListenPort() after this to get the actual bound port and determine success . Can be restarted.
      Throws:
        `SocketException`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`