|
Siena (v.1.5.5) API documentation | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsiena.comm.KAPacketReceiver
public class KAPacketReceiver
receives packets through a TCP port. Uses persistent TCP connections to receive one or more packets.
Field Summary | |
---|---|
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 Summary | |
---|---|
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. |
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. |
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. |
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 |
---|
public 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_timeout
public int receive_timeout
public static int DefaultMaxActiveConnections
setMaxActiveConnections(int)
Constructor Detail |
---|
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 used
java.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 used
java.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.IOException
Method Detail |
---|
public 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
PacketReceiver
receive
in interface PacketReceiver
PacketReceiverException
- in case an error occurrs
while reading.public int receive(byte[] buf, long timeout)
receive
in interface PacketReceiver
public void shutdown() throws PacketReceiverException
PacketReceiver
shutdown
in interface PacketReceiver
PacketReceiverException
public static int receive(java.net.Socket sock, byte[] buf) throws java.lang.InterruptedException, java.io.IOException
java.lang.InterruptedException
java.io.IOException
public byte[] uri()
address()
instead.
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.
public byte[] address()
:
host:
port
PacketReceiver.address()
protected static java.net.InetAddress guessMyIPAddress() throws java.net.UnknownHostException
java.net.UnknownHostException
protected static java.net.InetAddress guessMyIPAddress(java.net.ServerSocket s) throws java.net.UnknownHostException
java.net.UnknownHostException
protected static java.net.InetAddress guessMyIPAddress(java.net.DatagramSocket s) throws java.net.UnknownHostException
java.net.UnknownHostException
|
Siena (v.1.5.5) API documentation | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |