ist.palcom.base
Class DatagramSocket

java.lang.Object
  extended by ist.palcom.base.DatagramSocket
All Implemented Interfaces:
Channel
Direct Known Subclasses:
MulticastSocket

public class DatagramSocket
extends Object
implements Channel

This class implements a JVM version of ist.palcom.base.DatagramSocket. Before, it was implemented using Java non-blocking I/0 (Java NIO), but that is apparently not supported for multicast (see, e.g., http://directory.apache.org/subprojects/network/faq.html#multicast), so now it uses "normal" Java I/O.


Field Summary
protected static boolean onlyLoopback
          This flag is set if only the loopback interface is available.
protected  java.net.DatagramSocket socket
           
 
Constructor Summary
DatagramSocket()
           
DatagramSocket(int port)
           
 
Method Summary
 void close()
           
protected  java.net.DatagramSocket createSocket()
           
protected  java.net.DatagramSocket createSocket(int port)
           
 boolean dataAvailable()
          This method should only be called by the System class.
static String getLocalAddress()
           
 int getPort()
           
 int getReceiveBufferSize()
           
 int getSendBufferSize()
           
 boolean receive(DatagramPacket packet)
           
 void send(DatagramPacket p)
           
 void setReceiveBufferSize(int size)
           
 void setSendBufferSize(int size)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, println, toString
 

Field Detail

socket

protected java.net.DatagramSocket socket

onlyLoopback

protected static boolean onlyLoopback
This flag is set if only the loopback interface is available. In that case, localhost broadcast is used instead of multicast.

Constructor Detail

DatagramSocket

public DatagramSocket()

DatagramSocket

public DatagramSocket(int port)
Method Detail

createSocket

protected java.net.DatagramSocket createSocket()
                                        throws IOException
Throws:
IOException

createSocket

protected java.net.DatagramSocket createSocket(int port)
                                        throws IOException
Throws:
IOException

getPort

public int getPort()

send

public void send(DatagramPacket p)

receive

public boolean receive(DatagramPacket packet)
Returns:
True if a packet was received, false otherwise.

close

public void close()

dataAvailable

public boolean dataAvailable()
This method should only be called by the System class.

Specified by:
dataAvailable in interface Channel
See Also:
Channel.dataAvailable()

getLocalAddress

public static String getLocalAddress()
Returns:
The local host address (without port).

getReceiveBufferSize

public int getReceiveBufferSize()

getSendBufferSize

public int getSendBufferSize()

setReceiveBufferSize

public void setReceiveBufferSize(int size)

setSendBufferSize

public void setSendBufferSize(int size)