ist.palcom.base
Class DatagramSocket
java.lang.Object
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
|
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.
DatagramSocket
public DatagramSocket()
DatagramSocket
public DatagramSocket(int port)
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)