|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.kuka.comm.AbstractConnection
com.kuka.comm.net.NetConnection
com.kuka.comm.net.UdpConnection
public final class UdpConnection
Class to establish and use a UDP connection message exchange with other endpoints. Extends AbstractConnection
regarding to UDP.
| Field Summary |
|---|
| Fields inherited from class com.kuka.comm.net.NetConnection |
|---|
_inputBuffer, _localAddress, _outputBuffer, _remoteAddress |
| Constructor Summary | |
|---|---|
UdpConnection(InetAddress address,
int port)
Constructor which uses a specific target addresses and target port, which are used for sending and receiving datagrams. |
|
UdpConnection(InetSocketAddress remoteAddress)
Constructor which uses a specific target addresses and target port as InetSocketAddress, which are used
for sending and receiving datagrams. |
|
UdpConnection(InetSocketAddress remoteAddress,
InetSocketAddress localAddress)
Constructor which uses a specific target addresses and target port as InetSocketAddress, which are used
for sending and receiving datagrams. |
|
UdpConnection(UdpServer server,
InetSocketAddress remoteAddress)
Constructor which uses a specific target addresses and target port, which are used for sending and receiving datagrams. |
|
| Method Summary | |
|---|---|
void |
bindToPort(int portNumber)
Method used to bind this connection to a fixed internal port. |
void |
connect()
For a UDP connection the connect()-method ensures a functional DatagramSocket and
starts the connection in an new Thread. |
void |
disconnect()
The UDP connection will be freed from a previously binded address and port and closed afterwards. |
UdpConnectionStatistics |
getStatistics()
Returns general connection statistics about this connection. |
boolean |
isConnected()
Returns true of the connection is working as expected. |
boolean |
isConnectionless()
Checks if the underlying connection type implements a connectionless communication method. |
void |
send(Object msg)
This method will send the message. |
UdpConnection |
setTimeout(int timeout)
Sets the timeout, which determines the time the socket got block during DatagramSocket.receive(DatagramPacket)-call. |
String |
toString()
|
| Methods inherited from class com.kuka.comm.net.NetConnection |
|---|
getDecoder, getEncoder, getLocalAddress, getRemoteAddress, hasDecoder, hasEncoder, setDecoder, setEncoder, setInputBufferSize, setOutputBufferSize |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public UdpConnection(InetAddress address,
int port)
address - The address of the remote endpoint.port - The port number of the remote endpoint.public UdpConnection(InetSocketAddress remoteAddress)
InetSocketAddress, which are used
for sending and receiving datagrams.
remoteAddress - The Address and port number of remote endpoint as InetSocketAddress.
public UdpConnection(InetSocketAddress remoteAddress,
InetSocketAddress localAddress)
InetSocketAddress, which are used
for sending and receiving datagrams.
remoteAddress - The address and port number of remote endpoint as InetSocketAddress.localAddress - The local address and port number where the UDP socket should bind to InetSocketAddress.
public UdpConnection(UdpServer server,
InetSocketAddress remoteAddress)
server - The server that created this connection.remoteAddress - The address of the remote endpoint.| Method Detail |
|---|
public UdpConnection setTimeout(int timeout)
DatagramSocket.receive(DatagramPacket)-call. Any value different from zero will block the socket only for
this amount of time. If DatagramSocket.receive(DatagramPacket) is unable to finish successfully in given
time, an SocketTimeoutException will be raised. The socket could be used again for other operations (e.g.
DatagramSocket.send(DatagramPacket), DatagramSocket.close(), DatagramSocket.disconnect(),
...).
If an error occurs the timeout will in fact be set, but the socket won't use this timeout. Instead it will throw an exception which got caught by the default errorHandler, if no errorHandler has been defined manually.
timeout - Integer value stating the amount of milliseconds. A value of zero disables timeout.
public void send(Object msg)
throws ConnectionException
Connection
The message type is Object to ensure that all kinds of messages can be send by the same interface. Type
safety is ensured by the used Encoder, that must be able to handle the actual message type (i.e.
serialize it correctly), otherwise the message will not be send.
msg - The message to be send.
ConnectionException - if sending failspublic void connect()
connect()-method ensures a functional DatagramSocket and
starts the connection in an new Thread.
public void disconnect()
disconnect in interface Connectiondisconnect in class AbstractConnectionpublic UdpConnectionStatistics getStatistics()
Connection
getStatistics in interface ConnectiongetStatistics in class NetConnectionpublic void bindToPort(int portNumber)
Does a check for "Port out of range" to ensure that only valid ports are used. If given port number is out of
range an IllegalArgumentException is thrown.
portNumber - Could be any integer between 0 and 65535. Also zero would be a possible value (not specified).public boolean isConnected()
ConnectionConnection.isAbleToSend() and
Connection.isAbleToReceive() can be used to further check if sending or receiving of messages is possible.
public boolean isConnectionless()
Connectiontrue. A connectionless connection will behave in a slightly different way than a
connection-oriented connection, i.e. the connection will not be disconnected if the remote end point stops
working properly. Further, the method Connection.isConnected() only ensures that the local setup is working
properly but does not give any guarantees that the remote end point is working properly. Likewise,
Connection.isAbleToSend() will refer to the state of the local setup, but it will not guarantee that the message
will also be received or that the remote end point is even existing.
true, if the connection implements a connectionless communication method, false
otherwisepublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||