UDPPacketReceiver (Siena 2.0.4 API Documentation)
Date: 2015-05-17

siena.comm

## Class UDPPacketReceiver

- java.lang.Object
- - siena.comm.UDPPacketReceiver

- All Implemented Interfaces:
    PacketReceiver

      public class UDPPacketReceiver
      extends java.lang.Object
      implements PacketReceiver

  receives packets through a UDP port.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `AcceptPollingInterval` controls the accept-close workaround.
    `static int` | `DefaultPort`
    `static java.lang.String` | `Schema`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `UDPPacketReceiver(java.net.DatagramSocket s)`
    `UDPPacketReceiver(int port_number)` create a receiver listening to the given UDP port.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `byte[]` | `address()` external address of this packet receiver.
    `protected static java.net.InetAddress` | `guessMyIPAddress()`
    `protected static java.net.InetAddress` | `guessMyIPAddress(java.net.DatagramSocket s)`
    `protected static java.net.InetAddress` | `guessMyIPAddress(java.net.ServerSocket s)`
    `int` | `receive(byte[] buf)` receives a packet in the given buffer.
    `int` | `receive(byte[] buf, long timeout)` not yet implemented.
    `void` | `setHostName(java.lang.String hostname)` explicitly set the address of this packet receiver.
    `void` | `shutdown()` closes the receiver.

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

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

    - ### Methods inherited from interface siena.comm.PacketReceiver

      `address`

- - ### Field Detail

    - #### Schema

          public static final java.lang.String Schema

      See Also:
        Constant Field Values

    - #### DefaultPort

          public static final int DefaultPort

      See Also:
        Constant Field Values

    - #### AcceptPollingInterval

          public static int AcceptPollingInterval

      controls the accept-close workaround. See `TCPPacketReceiver.AcceptPollingInterval` for an explanation of this parameter.

  - ### Constructor Detail

    - #### UDPPacketReceiver

          public UDPPacketReceiver(int port_number)
                            throws java.io.IOException

      create a receiver listening to the given UDP port.
      Parameters:
        `port_number` - must be a valid UDP port number, or it can be 0 in which case a random port is used
      Throws:
        `java.io.IOException`

    - #### UDPPacketReceiver

          public UDPPacketReceiver(java.net.DatagramSocket s)
                            throws java.net.UnknownHostException,
                                   java.io.IOException

      Throws:
        `java.net.UnknownHostException`
        `java.io.IOException`

  - ### Method Detail

    - #### setHostName

          public void setHostName(java.lang.String hostname)

      explicitly set the address of this packet receiver. This method allows to set the host name or IP address explicitly. This might be necessary in the cases in which the java VM can not figure that out reliably.

    - #### shutdown

          public void shutdown()

      Description copied from interface: `PacketReceiver`
      closes the receiver.
      Specified by:
        `shutdown` in interface `PacketReceiver`

    - #### receive

          public int receive(byte[] buf)
                      throws PacketReceiverException

      Description copied from interface: `PacketReceiver`
      receives a packet in the given buffer. This method must be reentrant. Siena clients and servers must be able to use several threads to receive packets from the same receiver.
      Specified by:
        `receive` in interface `PacketReceiver`
      Returns:
        the number of bytes read into the buffer. The return value must not be negative. On error conditions, this method must throw an exception.
      Throws:
        `PacketReceiverException` - in case an error occurrs while reading.

    - #### receive

          public int receive(byte[] buf,
                    long timeout)

      not yet implemented.
      Specified by:
        `receive` in interface `PacketReceiver`
      Returns:
        the number of bytes read into the buffer. The return value must not be negative. On error conditions, this method must throw an exception.

    - #### address

          public byte[] address()

      external address of this packet receiver. Uses the following schema syntax:
      schema`:`host`:`port
      See Also:
        `PacketReceiver.address()`

    - #### guessMyIPAddress

          protected static java.net.InetAddress guessMyIPAddress()
                                                          throws java.net.UnknownHostException

      Throws:
        `java.net.UnknownHostException`

    - #### guessMyIPAddress

          protected static java.net.InetAddress guessMyIPAddress(java.net.ServerSocket s)
                                                          throws java.net.UnknownHostException

      Throws:
        `java.net.UnknownHostException`

    - #### guessMyIPAddress

          protected static java.net.InetAddress guessMyIPAddress(java.net.DatagramSocket s)
                                                          throws java.net.UnknownHostException

      Throws:
        `java.net.UnknownHostException`

Copyright © 2000-2005 University of Colorado.
Copyright © 2005-2011 Antonio Carzaniga.
This documentation is maintained by Antonio Carzaniga