public class KAPacketReceiver extends java.lang.Object implements PacketReceiver
| Modifier and Type | Field and Description |
|---|---|
static int |
AcceptPollingInterval
controls the accept-close workaround.
|
static int |
DefaultMaxActiveConnections
default limit for active connections.
|
static int |
DefaultPort |
static int |
DefaultReceiveTimeout
default value for the receive timeout.
|
int |
receive_timeout
limits the duration of blocking input when receiving packets.
|
static java.lang.String |
Schema |
| Constructor and Description |
|---|
KAPacketReceiver()
creates a receiver listening to the a random port.
|
KAPacketReceiver(int port_number)
creates a receiver listening to the given port.
|
KAPacketReceiver(int port_number,
int qsize)
creates a receiver listening to the given port with a given
maximum queue for TCP connections.
|
KAPacketReceiver(java.net.ServerSocket s)
creates a receiver listening to the given 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.
|
static int |
receive(java.net.Socket sock,
byte[] buf) |
void |
setHostName(java.lang.String hostname)
explicitly sets the address of this packet receiver.
|
void |
setMaxActiveConnections(int m)
limits the number of active connections.
|
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 static int DefaultReceiveTimeout
receive_timeoutpublic int receive_timeout
public static int DefaultMaxActiveConnections
setMaxActiveConnections(int)public KAPacketReceiver()
throws java.io.IOException
java.io.IOException - if an I/O error occurs when opening the
socket port.public KAPacketReceiver(int port_number)
throws java.io.IOException
port_number - must be a valid TCP port number, or it can
be 0 in which case a random port is usedjava.io.IOException - if an I/O error occurs when opening the
socket. typically, when the given port is already in use.public KAPacketReceiver(int port_number,
int qsize)
throws java.io.IOException
port_number - must be a valid TCP port number, or it can
be 0 in which case a random port is usedjava.io.IOException - if an I/O error occurs when opening the
socket. typically, when the given port is already in use.public KAPacketReceiver(java.net.ServerSocket s)
throws java.io.IOException
s - server socket used to accept connections.java.net.UnknownHostException - if an error occurrs while
resolving the hostname for this host.java.io.IOExceptionpublic void setMaxActiveConnections(int m)
m active
connections. If a new connection is accepted when
m connections are active, the new accepted
connections will replace the oldest active connection.
When the limit is lowered and x > m connections are active, the oldest x - m connections are closed.
public void setHostName(java.lang.String hostname)
public 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 void shutdown()
throws PacketReceiverException
PacketReceivershutdown in interface PacketReceiverPacketReceiverExceptionpublic static int receive(java.net.Socket sock,
byte[] buf)
throws java.lang.InterruptedException,
java.io.IOException
java.lang.InterruptedExceptionjava.io.IOExceptionpublic 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