us.ihmc.utilities.io
Class DatagramChannelInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by us.ihmc.utilities.io.DatagramChannelInputStream
All Implemented Interfaces:
java.io.Closeable

public class DatagramChannelInputStream
extends java.io.InputStream

DatagramInputStream. Each time you read, it'll give you data from the last packet if there is some, or wait to receive a new packet to replenish the buffer. If the buffer has data, it'll just ignore the incoming DataGrams. May receive data out of order, but probably not a problem on a direct connection. Shouldn't concatenate this with a BufferedInputStream, like you would with TCP, if you want to ignore packets until you are ready for the next one.


Constructor Summary
DatagramChannelInputStream(int port)
           
 
Method Summary
 int read()
          This will block once out of data and need to wait for a new DatagramPacket.
 int read(byte[] b)
          This will block once out of data and need to wait for a new DatagramPacket.
 int read(byte[] b, int offset, int length)
          This will block once out of data and need to wait for a new DatagramPacket.
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatagramChannelInputStream

public DatagramChannelInputStream(int port)
                           throws java.net.SocketException,
                                  java.io.IOException
Throws:
java.net.SocketException
java.io.IOException
Method Detail

read

public int read()
         throws java.io.IOException
This will block once out of data and need to wait for a new DatagramPacket.

Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
This will block once out of data and need to wait for a new DatagramPacket.

Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int offset,
                int length)
         throws java.io.IOException
This will block once out of data and need to wait for a new DatagramPacket.

Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException