Siena (v.1.5.5) API documentation

siena.comm
Class UDPPacketReceiver

java.lang.Object
  extended by siena.comm.UDPPacketReceiver
All Implemented Interfaces:
PacketReceiver

public class UDPPacketReceiver
extends java.lang.Object
implements PacketReceiver

receives packets through a UDP port.


Field Summary
static int AcceptPollingInterval
          controls the accept-close workaround.
static int DefaultPort
           
static java.lang.String Schema
           
 
Constructor Summary
UDPPacketReceiver(java.net.DatagramSocket s)
           
UDPPacketReceiver(int port_number)
          create a receiver listening to the given UDP port.
 
Method Summary
 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.
 byte[] uri()
          Deprecated. since 1.4.0. Please use address() instead.
 
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, uri
 

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.

uri

public byte[] uri()
Deprecated. since 1.4.0. Please use address() instead.

This method has been replaced by address(). The reason for this change is more conceptual than practical: the term "address" is more appropriate than the term "uri" because it provides a way to reach a PacketReceiver, rather than an identifier.


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

Siena (v.1.5.5) API documentation

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