rescuecore
Class LongUDPSocket

java.lang.Object
  |
  +--rescuecore.LongUDPSocket

public class LongUDPSocket
extends java.lang.Object

The LongUDPSocket class encapsulates the sending and receiving of LongUDPMessages to and from the kernal. Messages are received asynchronously and stored in a queue.


Constructor Summary
LongUDPSocket()
          Generate a new LongUDPSocket
 
Method Summary
 void close()
          Close the socket
 LongUDPMessage receive(int timeout)
          Fetch a LongUDPMessage from the receive queue.
 void send(LongUDPMessage msg, java.net.InetAddress destination, int port)
          Send a message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LongUDPSocket

public LongUDPSocket()
              throws java.net.SocketException
Generate a new LongUDPSocket

Method Detail

close

public void close()
Close the socket


send

public void send(LongUDPMessage msg,
                 java.net.InetAddress destination,
                 int port)
          throws java.io.IOException
Send a message

Parameters:
msg - The LongUDPMessage to send
destination - The destination address
port - The destination port
Throws:
java.io.IOException - if something goes wrong during sending

receive

public LongUDPMessage receive(int timeout)
                       throws java.io.IOException
Fetch a LongUDPMessage from the receive queue. If the queue is empty then this method will wait for the specified timeout (in ms, -1 to wait forever). If the queue is still empty after this wait then null is returned

Parameters:
timeout - The maximum time to wait, in ms. If this is negative then this method will wait forever (or until interrupted).
Returns:
The next LongUDPMessage in the receive queue
Throws:
java.io.IOException - if there is an error during receiving