public class UDPPacketReceiver extends java.lang.Object implements PacketReceiver
| Modifier and Type | Field and Description |
|---|---|
static int |
AcceptPollingInterval
controls the accept-close workaround.
|
static int |
DefaultPort |
static java.lang.String |
Schema |
| Constructor and Description |
|---|
UDPPacketReceiver(java.net.DatagramSocket s) |
UDPPacketReceiver(int port_number)
create a receiver listening to the given UDP port.
|
| 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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddresspublic static final java.lang.String Schema
public static final int DefaultPort
public static int AcceptPollingInterval
TCPPacketReceiver.AcceptPollingInterval for an
explanation of this parameter.public UDPPacketReceiver(int port_number)
throws java.io.IOException
port_number - must be a valid UDP port number, or it can
be 0 in which case a random port is usedjava.io.IOExceptionpublic UDPPacketReceiver(java.net.DatagramSocket s)
throws java.net.UnknownHostException,
java.io.IOException
java.net.UnknownHostExceptionjava.io.IOExceptionpublic void setHostName(java.lang.String hostname)
public void shutdown()
PacketReceivershutdown in interface PacketReceiverpublic int receive(byte[] buf)
throws PacketReceiverException
PacketReceiverreceive in interface PacketReceiverPacketReceiverException - in case an error occurrs
while reading.public int receive(byte[] buf,
long timeout)
receive in interface PacketReceiverpublic byte[] address()
:host:portPacketReceiver.address()protected static java.net.InetAddress guessMyIPAddress()
throws java.net.UnknownHostException
java.net.UnknownHostExceptionprotected static java.net.InetAddress guessMyIPAddress(java.net.ServerSocket s)
throws java.net.UnknownHostException
java.net.UnknownHostExceptionprotected static java.net.InetAddress guessMyIPAddress(java.net.DatagramSocket s)
throws java.net.UnknownHostException
java.net.UnknownHostException
Copyright © 2005-2011 Antonio Carzaniga.
This documentation is maintained by Antonio Carzaniga