Class QuanserStream

java.lang.Object
com.quanser.communications.QuanserStream

public class QuanserStream extends Object
The Quanser Stream API is a generic buffered communication protocol API based upon the Quanser Communications API.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Enumerates the different byte orders.
    static enum 
    Enumerates the different character formats available for textual communications.
    static class 
    Defines the flags used by the poll method.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a QuanserStream object.
  • Method Summary

    Modifier and Type
    Method
    Description
    Accepts a connection to a listening communication stream by a client and uses default send and receive buffer sizes.
    accept(int sendBufferSize, int receiveBufferSize)
    Accepts a connection to a listening communication stream by a client.
    void
    Closes the stream.
    void
    Closes all streams currently connected or listening.
    void
    Connects to a server listening on the given URI using blocking I/O and default send and receive buffer sizes.
    boolean
    connect(String uri, boolean nonBlocking)
    Connects to a server listening on the given URI using blocking or non-blocking I/O and default send and receive buffer sizes.
    boolean
    connect(String uri, boolean nonBlocking, int sendBufferSize, int receiveBufferSize)
    Connects to a server listening on the given URI using blocking or non-blocking I/O.
    void
    connect(String uri, int sendBufferSize, int receiveBufferSize)
    Connects to a server listening on the given URI using blocking I/O.
    void
    connect(URI uri)
    Connects to a server listening on the given URI using blocking I/O and default send and receive buffer sizes.
    boolean
    connect(URI uri, boolean nonBlocking)
    Connects to a server listening on the given URI using blocking or non-blocking I/O and default send and receive buffer sizes.
    boolean
    connect(URI uri, boolean nonBlocking, int sendBufferSize, int receiveBufferSize)
    Connects to a server listening on the given URI using blocking or non-blocking I/O.
    void
    connect(URI uri, int sendBufferSize, int receiveBufferSize)
    Connects to a server listening on the given URI using blocking I/O.
    boolean
    Flushes the stream send buffer to the underlying communication channel.
    Returns the character format of the stream.
    Returns an InputStream object for this QuanserStream.
    Returns an OutputStream object for this QuanserStream.
    int
    ignore(int numBytes)
    Reads the specified number of bytes from the stream and discards them.
    void
    Establishes a listening server stream which listens on the given URI using blocking I/O.
    void
    listen(String uri, boolean nonBlocking)
    Establishes a listening server stream which listens on the given URI using blocking or non-blocking I/O.
    void
    listen(URI uri)
    Establishes a listening server stream which listens on the given URI using blocking I/O.
    void
    listen(URI uri, boolean nonBlocking)
    Establishes a listening server stream which listens on the given URI using blocking or non-blocking I/O.
    int
    poll(double timeout, int flags)
    Polls the stream for events, such as whether it is possible to send or receive without blocking.
    int
    receive(byte[] buffer)
    Reads the specified number of 8-bit integers (i.e., bytes) from the stream.
    int
    receive(double[] buffer)
    Reads the specified number of 64-bit, double-precision, floating-point numbers (i.e., doubles) from the stream.
    int
    receive(float[] buffer)
    Reads the specified number of 32-bit, single-precision, floating-point numbers (i.e., floats) from the stream.
    int
    receive(int[] buffer)
    Reads the specified number of 32-bit integers (i.e., ints) from the stream.
    int
    receive(long[] buffer)
    Reads the specified number of 64-bit integers (i.e., longs) from the stream.
    int
    receive(short[] buffer)
    Reads the specified number of 16-bit integers (i.e., shorts) from the stream.
    int
    receiveArray(byte[] buffer)
    Reads an array of 8-bit integers (i.e., bytes) from the stream.
    int
    receiveArray(double[] buffer)
    Reads an array of 64-bit, double-precision, floating-point numbers (i.e., doubles) from the stream.
    int
    receiveArray(float[] buffer)
    Reads an array of 32-bit, single-precision, floating-point numbers (i.e., floats) from the stream.
    int
    receiveArray(int[] buffer)
    Reads an array of 32-bit integers (i.e., ints) from the stream.
    int
    receiveArray(long[] buffer)
    Reads an array of 64-bit integers (i.e., longs) from the stream.
    int
    receiveArray(short[] buffer)
    Reads an array of 16-bit integers (i.e., shorts) from the stream.
    int
    send(byte[] buffer)
    Writes the specified number of 8-bit integers (i.e., bytes) to the stream send buffer.
    int
    send(double[] buffer)
    Writes the specified number of 64-bit, double-precision, floating-point (i.e., doubles) to the stream send buffer.
    int
    send(float[] buffer)
    Writes the specified number of 32-bit, single-precision, floating-point (i.e., floats) to the stream send buffer.
    int
    send(int[] buffer)
    Writes the specified number of 32-bit integers (i.e., ints) to the stream send buffer.
    int
    send(long[] buffer)
    Writes the specified number of 64-bit integers (i.e., longs) to the stream send buffer.
    int
    send(short[] buffer)
    Writes the specified number of 16-bit integers (i.e., shorts) to the stream send buffer.
    int
    sendArray(byte[] buffer)
    Writes the specified array of 8-bit integers (i.e., bytes) to the stream send buffer.
    int
    sendArray(double[] buffer)
    Writes the specified array of 64-bit, double-precision, floating-point numbers (i.e., doubles) to the stream send buffer.
    int
    sendArray(float[] buffer)
    Writes the specified array of 32-bit, single-precision, floating-point numbers (i.e., floats) to the stream send buffer.
    int
    sendArray(int[] buffer)
    Writes the specified array of 32-bit integers (i.e., ints) to the stream send buffer.
    int
    sendArray(long[] buffer)
    Writes the specified array of 64-bit integers (i.e., longs) to the stream send buffer.
    int
    sendArray(short[] buffer)
    Writes the specified array of 16-bit integers (i.e., shorts) to the stream send buffer.
    int
    sendByte(byte value)
    Writes a single 8-bit integer (i.e., byte) to the stream send buffer.
    int
    sendDouble(double value)
    Writes a single 64-bit, double-precision, floating-point (i.e., double) to the stream send buffer.
    int
    sendFloat(float value)
    Writes a single 32-bit, single-precision, floating-point (i.e., float) to the stream send buffer.
    int
    sendInt(int value)
    Writes a single 32-bit integer (i.e., int) to the stream send buffer.
    int
    sendLong(long value)
    Writes a single 64-bit integer (i.e., long) to the stream send buffer.
    int
    sendShort(short value)
    Writes a single 16-bit integer (i.e., short) to the stream send buffer.
    void
    Configures the byte order used by methods that send and receive various data types, or arrays of types.
    void
    Configures whether the methods that send and receive characters convert between the local character format and another character format when reading and writing to the underlying communication channel.
    void
    setSwapBytes(boolean swap)
    Configures whether the methods that send and receive various data types, or arrays of types, swap the bytes in the individual values in order to account for endian differences between the client and server.
    void
    Shuts down send and/or receive operations in preparation for closing the stream.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • QuanserStream

      public QuanserStream()
      Constructs a QuanserStream object. The object is not connected or listening. One of the connect or listen methods must be called before using the other methods of this object.
  • Method Details

    • getInputStream

      public InputStream getInputStream() throws IllegalBlockingModeException
      Returns an InputStream object for this QuanserStream. If this input stream has an associated channel then the resulting input stream delegates all of its operations to the channel. If the channel is in non-blocking I/O mode then the input stream's InputStream operation will throw an IllegalBlockingModeException.
      Returns:
      An InputStream object for reading bytes from this QuanserStream.
      Throws:
      IllegalBlockingModeException - If the underlying stream channel is in non-blocking I/O mode.
    • getOutputStream

      public OutputStream getOutputStream() throws IllegalBlockingModeException
      Returns an OutputStream object for this QuanserStream. If this output stream has an associated channel then the resulting output stream delegates all of its operations to the channel. If the channel is in non-blocking I/O mode then the output stream's getOutputStream() operation will throw an IllegalBlockingModeException.
      Returns:
      An OutputStream object for writing bytes to this QuanserStream. An output stream accepts output bytes and sends them to some sink.
      Throws:
      IllegalBlockingModeException - If the underlying stream channel is in non-blocking I/O mode.
    • listen

      public void listen(String uri, boolean nonBlocking) throws IOException, URISyntaxException
      Establishes a listening server stream which listens on the given URI using blocking or non-blocking I/O. This method establishes a server stream which listens on the given URI. The URI specifies the protocol, address, port and options associated with the server stream. The Stream API uses the protocol to load a protocol-specific driver.
      Parameters:
      uri - A URI string indicating the stream on which to listen.
      nonBlocking - Set to true to prevent accept calls from blocking. Any client connections accepted will also be non-blocking. If this parameter is set to false then the accept call will block until a client connects or shutdown is invoked, and any client connections accepted will also use blocking I/O.
      Throws:
      IOException - Failed to listen on the given URI. If a listening stream cannot be opened then an exception is thrown. This situation typically arises if the underlying protocol cannot acquire the resources it needs. For example, the TCP/IP driver may not be able to listen on a given port because another server is already using that port.
      URISyntaxException - Invalid URI specified.
    • listen

      public void listen(URI uri, boolean nonBlocking) throws IOException, URISyntaxException
      Establishes a listening server stream which listens on the given URI using blocking or non-blocking I/O. This method establishes a server stream which listens on the given URI. The URI specifies the protocol, address, port and options associated with the server stream. The Stream API uses the protocol to load a protocol-specific driver.
      Parameters:
      uri - A URI indicating the stream on which to listen.
      nonBlocking - Set to true to prevent accept calls from blocking. Any client connections accepted will also be non-blocking. If this parameter is set to false then the accept call will block until a client connects or shutdown is invoked, and any client connections accepted will also use blocking I/O.
      Throws:
      IOException - Failed to listen on the given URI. If a listening stream cannot be opened then an exception is thrown. This situation typically arises if the underlying protocol cannot acquire the resources it needs. For example, the TCP/IP driver may not be able to listen on a given port because another server is already using that port.
      URISyntaxException - Invalid URI specified.
    • listen

      public void listen(String uri) throws IOException, URISyntaxException
      Establishes a listening server stream which listens on the given URI using blocking I/O. This method establishes a server stream which listens on the given URI. It uses blocking I/O. To use non-blocking I/O, use the listen(String, boolean) method. The URI specifies the protocol, address, port and options associated with the server stream. The Stream API uses the protocol to load a protocol-specific driver.
      Parameters:
      uri - A URI string indicating the stream on which to listen.
      Throws:
      IOException - Failed to listen on the given URI. If a listening stream cannot be opened then an exception is thrown. This situation typically arises if the underlying protocol cannot acquire the resources it needs. For example, the TCP/IP driver may not be able to listen on a given port because another server is already using that port.
      URISyntaxException - Invalid URI specified.
    • listen

      public void listen(URI uri) throws IOException, URISyntaxException
      Establishes a listening server stream which listens on the given URI using blocking I/O. This method establishes a server stream which listens on the given URI. It uses blocking I/O. To use non-blocking I/O, use the listen(URI, boolean) method. The URI specifies the protocol, address, port and options associated with the server stream. The Stream API uses the protocol to load a protocol-specific driver.
      Parameters:
      uri - A URI indicating the stream on which to listen.
      Throws:
      IOException - Failed to listen on the given URI. If a listening stream cannot be opened then an exception is thrown. This situation typically arises if the underlying protocol cannot acquire the resources it needs. For example, the TCP/IP driver may not be able to listen on a given port because another server is already using that port.
      URISyntaxException - Invalid URI specified.
    • connect

      public boolean connect(String uri, boolean nonBlocking, int sendBufferSize, int receiveBufferSize) throws IOException, URISyntaxException
      Connects to a server listening on the given URI using blocking or non-blocking I/O. This method connects to a listening stream referenced by the given URI. The URI specifies the protocol, address, port and options associated with the server stream. The Stream object uses the protocol to load a protocol-specific driver.
      Parameters:
      uri - A URI String indicating the listening stream to which to connect.
      nonBlocking - Set to true to make the client connection use non-blocking I/O. Otherwise blocking I/O will be used. If the nonBlocking flag is set to false, then this method will block until the connection is made. Some protocols allow a timeout to be specified in the URI or have a default timeout such that the connect will not block indefinitely. If the nonBlocking flag is set to true, then this method will not block. If the connection is completed immediately then true is returned. If the connection cannot be completed immediately then false is returned. In this case, the connection may be completed using the poll(double, int) method with the PollFlag.connect flag.
      sendBufferSize - The size of the buffer to use for sending data over the stream, in bytes. This buffer is referred to as the stream send buffer in this documentation.
      receiveBufferSize - The size of the buffer to use for receiving data over the stream, in bytes. This buffer is referred to as the stream receive buffer in this documentation.
      Returns:
      This method returns true if the connection is established. If non-blocking I/O is being used, then it may also return false, which indicates that the connection is in progress but has not yet been completed. Finish establishing the connection, in this case, by using the poll(double, int) method with the PollFlag.connect flag.
      Throws:
      IOException - Failed to connect to the listening stream. If the connection cannot be made then an exception is thrown. This situation typically arises if there is no server listening on the given URI. For non-blocking I/O, an exception may not be thrown until the poll(double, int) call if the connect method returns false, since the connection is still in progress in that case.
      URISyntaxException - Invalid URI specified.
    • connect

      public boolean connect(URI uri, boolean nonBlocking, int sendBufferSize, int receiveBufferSize) throws IOException, URISyntaxException
      Connects to a server listening on the given URI using blocking or non-blocking I/O. This method connects to a listening stream referenced by the given URI. The URI specifies the protocol, address, port and options associated with the server stream. The Stream object uses the protocol to load a protocol-specific driver.
      Parameters:
      uri - A URI indicating the listening stream to which to connect.
      nonBlocking - Set to true to make the client connection use non-blocking I/O. Otherwise blocking I/O will be used. If the nonBlocking flag is set to false, then this method will block until the connection is made. Some protocols allow a timeout to be specified in the URI or have a default timeout such that the connect will not block indefinitely. If the nonBlocking flag is set to true, then this method will not block. If the connection is completed immediately then true is returned. If the connection cannot be completed immediately then false is returned. In this case, the connection may be completed using the poll(double, int) method with the PollFlag.connect flag.
      sendBufferSize - The size of the buffer to use for sending data over the stream, in bytes. This buffer is referred to as the stream send buffer in this documentation.
      receiveBufferSize - The size of the buffer to use for receiving data over the stream, in bytes. This buffer is referred to as the stream receive buffer in this documentation.
      Returns:
      This method returns true if the connection is established. If non-blocking I/O is being used, then it may also return false, which indicates that the connection is in progress but has not yet been completed. Finish establishing the connection, in this case, by using the poll(double, int) method with the PollFlag.connect flag.
      Throws:
      IOException - Failed to connect to the listening stream. If the connection cannot be made then an exception is thrown. This situation typically arises if there is no server listening on the given URI. For non-blocking I/O, an exception may not be thrown until the poll(double, int) call if the connect method returns false, since the connection is still in progress in that case.
      URISyntaxException - Invalid URI specified.
    • connect

      public boolean connect(String uri, boolean nonBlocking) throws IOException, URISyntaxException
      Connects to a server listening on the given URI using blocking or non-blocking I/O and default send and receive buffer sizes. This method connects to a listening stream referenced by the given URI. The URI specifies the protocol, address, port and options associated with the server stream. The Stream object uses the protocol to load a protocol-specific driver.
      Parameters:
      uri - A String URI indicating the listening stream to which to connect.
      nonBlocking - Set to true to make the client connection use non-blocking I/O. Otherwise blocking I/O will be used. If the nonBlocking flag is set to false, then this method will block until the connection is made. Some protocols allow a timeout to be specified in the URI or have a default timeout such that the connect will not block indefinitely. If the nonBlocking flag is set to true, then this method will not block. If the connection is completed immediately then true is returned. If the connection cannot be completed immediately then false is returned. In this case, the connection may be completed using the poll(double, int) method with the PollFlag.connect flag.
      Returns:
      This method returns true if the connection is established. If non-blocking I/O is being used, then it may also return false, which indicates that the connection is in progress but has not yet been completed. Finish establishing the connection, in this case, by using the poll(double, int) method with the PollFlag.connect flag.
      Throws:
      IOException - Failed to connect to the listening stream. If the connection cannot be made then an exception is thrown. This situation typically arises if there is no server listening on the given URI. For non-blocking I/O, an exception may not be thrown until the poll(double, int) call if the connect method returns false, since the connection is still in progress in that case.
      URISyntaxException - Invalid URI specified.
    • connect

      public boolean connect(URI uri, boolean nonBlocking) throws IOException, URISyntaxException
      Connects to a server listening on the given URI using blocking or non-blocking I/O and default send and receive buffer sizes. This method connects to a listening stream referenced by the given URI. The URI specifies the protocol, address, port and options associated with the server stream. The Stream object uses the protocol to load a protocol-specific driver.
      Parameters:
      uri - A URI indicating the listening stream to which to connect.
      nonBlocking - Set to true to make the client connection use non-blocking I/O. Otherwise blocking I/O will be used. If the nonBlocking flag is set to false, then this method will block until the connection is made. Some protocols allow a timeout to be specified in the URI or have a default timeout such that the connect will not block indefinitely. If the nonBlocking flag is set to true, then this method will not block. If the connection is completed immediately then true is returned. If the connection cannot be completed immediately then false is returned. In this case, the connection may be completed using the poll(double, int) method with the PollFlag.connect flag.
      Returns:
      This method returns true if the connection is established. If non-blocking I/O is being used, then it may also return false, which indicates that the connection is in progress but has not yet been completed. Finish establishing the connection, in this case, by using the poll(double, int) method with the PollFlag.connect flag.
      Throws:
      IOException - Failed to connect to the listening stream. If the connection cannot be made then an exception is thrown. This situation typically arises if there is no server listening on the given URI. For non-blocking I/O, an exception may not be thrown until the poll(double, int) call if the connect method returns false, since the connection is still in progress in that case.
      URISyntaxException - Invalid URI specified.
    • connect

      public void connect(String uri, int sendBufferSize, int receiveBufferSize) throws IOException, URISyntaxException
      Connects to a server listening on the given URI using blocking I/O. This method connects to a listening stream referenced by the given URI. The URI specifies the protocol, address, port and options associated with the server stream. The Stream object uses the protocol to load a protocol-specific driver. This method uses blocking I/O. Hence, it will block until the connection is made. Some protocols allow a timeout to be specified in the URI or have a default timeout such that the connect will not block indefinitely.
      Parameters:
      uri - A String URI indicating the listening stream to which to connect.
      sendBufferSize - The size of the buffer to use for sending data over the stream, in bytes. This buffer is referred to as the stream send buffer in this documentation.
      receiveBufferSize - The size of the buffer to use for receiving data over the stream, in bytes. This buffer is referred to as the stream receive buffer in this documentation.
      Throws:
      IOException - Failed to connect to the listening stream. If the connection cannot be made then an exception is thrown. This situation typically arises if there is no server listening on the given URI. For non-blocking I/O, an exception may not be thrown until the poll(double, int) call if the connect method returns false, since the connection is still in progress in that case.
      URISyntaxException - Invalid URI specified.
    • connect

      public void connect(URI uri, int sendBufferSize, int receiveBufferSize) throws IOException, URISyntaxException
      Connects to a server listening on the given URI using blocking I/O. This method connects to a listening stream referenced by the given URI. The URI specifies the protocol, address, port and options associated with the server stream. The Stream object uses the protocol to load a protocol-specific driver. This method uses blocking I/O. Hence, it will block until the connection is made. Some protocols allow a timeout to be specified in the URI or have a default timeout such that the connect will not block indefinitely.
      Parameters:
      uri - A URI indicating the listening stream to which to connect.
      sendBufferSize - The size of the buffer to use for sending data over the stream, in bytes. This buffer is referred to as the stream send buffer in this documentation.
      receiveBufferSize - The size of the buffer to use for receiving data over the stream, in bytes. This buffer is referred to as the stream receive buffer in this documentation.
      Throws:
      IOException - Failed to connect to the listening stream. If the connection cannot be made then an exception is thrown. This situation typically arises if there is no server listening on the given URI. For non-blocking I/O, an exception may not be thrown until the poll(double, int) call if the connect method returns false, since the connection is still in progress in that case.
      URISyntaxException - Invalid URI specified.
    • connect

      public void connect(String uri) throws IOException, URISyntaxException
      Connects to a server listening on the given URI using blocking I/O and default send and receive buffer sizes. This method connects to a listening stream referenced by the given URI. The URI specifies the protocol, address, port and options associated with the server stream. The Stream object uses the protocol to load a protocol-specific driver. This method uses blocking I/O. Hence, it will block until the connection is made. Some protocols allow a timeout to be specified in the URI or have a default timeout such that the connect will not block indefinitely.
      Parameters:
      uri - A String URI indicating the listening stream to which to connect.
      Throws:
      IOException - Failed to connect to the listening stream. If the connection cannot be made then an exception is thrown. This situation typically arises if there is no server listening on the given URI. For non-blocking I/O, an exception may not be thrown until the poll(double, int) call if the connect method returns false, since the connection is still in progress in that case.
      URISyntaxException - Invalid URI specified.
    • connect

      public void connect(URI uri) throws IOException, URISyntaxException
      Connects to a server listening on the given URI using blocking I/O and default send and receive buffer sizes. This method connects to a listening stream referenced by the given URI. The URI specifies the protocol, address, port and options associated with the server stream. The Stream object uses the protocol to load a protocol-specific driver. This method uses blocking I/O. Hence, it will block until the connection is made. Some protocols allow a timeout to be specified in the URI or have a default timeout such that the connect will not block indefinitely.
      Parameters:
      uri - A URI indicating the listening stream to which to connect.
      Throws:
      IOException - Failed to connect to the listening stream. If the connection cannot be made then an exception is thrown. This situation typically arises if there is no server listening on the given URI. For non-blocking I/O, an exception may not be thrown until the poll(double, int) call if the connect method returns false, since the connection is still in progress in that case.
      URISyntaxException - Invalid URI specified.
    • accept

      public QuanserStream accept(int sendBufferSize, int receiveBufferSize) throws IOException
      Accepts a connection to a listening communication stream by a client. This method accepts a connection to a listening communication stream by a client. The client connects using one of the connect methods. If the listen method that created the stream was called with nonBlocking flag set to false then this call will block until a client connects. The client stream will also be a blocking stream. If the listen method that created the stream was called with nonBlocking flag set to true then this call will not block. If there is no pending client connection then it will return a null reference. The poll(double, int) method may be used with the PollFlag.accept flag to determine when a client connection is pending. In this case, the client stream returned will also be a non-blocking stream.
      Parameters:
      sendBufferSize - The size of the buffer to use for sending data over the stream, in bytes. This buffer is referred to as the stream send buffer in this documentation.
      receiveBufferSize - The size of the buffer to use for receiving data over the stream, in bytes. This buffer is referred to as the stream receive buffer in this documentation.
      Returns:
      This method returns This method returns a QuanserStream object representing a new connection to the client if the connection is established. If non-blocking I/O is being used, then it may also return null, which indicates that no client connection was pending. Use the poll(double, int) method with the PollFlag.accept flag to determine when a client connection is pending.
      Throws:
      IOException - If the connection cannot be accepted then an exception is thrown. This situation typically arises if the accept method is called on a connected stream rather than a listening stream.
    • accept

      public QuanserStream accept() throws IOException
      Accepts a connection to a listening communication stream by a client and uses default send and receive buffer sizes. This method accepts a connection to a listening communication stream by a client. The client connects using one of the connect methods. If the listen method that created the stream was called with nonBlocking flag set to false then this call will block until a client connects. The client stream will also be a blocking stream. If the listen method that created the stream was called with nonBlocking flag set to true then this call will not block. If there is no pending client connection then it will return a null reference. The poll(double, int) method may be used with the PollFlag.accept flag to determine when a client connection is pending. In this case, the client stream returned will also be a non-blocking stream.
      Returns:
      This method returns This method returns a QuanserStream object representing a new connection to the client if the connection is established. If non-blocking I/O is being used, then it may also return null, which indicates that no client connection was pending. Use the poll(double, int) method with the PollFlag.accept flag to determine when a client connection is pending.
      Throws:
      IOException - If the connection cannot be accepted then an exception is thrown. This situation typically arises if the accept method is called on a connected stream rather than a listening stream.
    • setSwapBytes

      public void setSwapBytes(boolean swap) throws IOException
      Configures whether the methods that send and receive various data types, or arrays of types, swap the bytes in the individual values in order to account for endian differences between the client and server. This method may be used to cause the bytes within shorts, integers, doubles and other data types to be swapped by the QuanserStream object to account for endian differences between the two endpoints of the connection. The QuanserStream object does not detect the endianness of the peer. Calling this method with the swap flag set to true causes the bytes to be swapped unconditionally. Byte swapping is only necessary when communicating between processors that use a different endianness. For example, Intel processors are little endian (LSB first) while Motorola processors tend to be big endian (MSB first). By default, no byte swapping takes place. Whether byte swapping is necessary may be determined simply by sending 0x1234 as a short and seeing if it arrives as the same number or 0x3421.
      Parameters:
      swap - If this parameter is true then the QuanserStream object will swap the bytes within primitive data types when sending and receiving those types, or arrays of those types. Otherwise, no byte swapping will occur.
      Throws:
      IOException - If byte-swapping cannot be configured then an exception is thrown. This situation should never occur unless the underlying stream has been closed.
    • setByteOrder

      public void setByteOrder(QuanserStream.ByteOrder byteOrder) throws IOException
      Configures the byte order used by methods that send and receive various data types, or arrays of types. Byte swapping will occur in the individual values, if necessary, to achieve the desired byte ordering in order to account for endian differences between the client and server. This method may be used to cause the bytes within shorts, integers, doubles and other data types to be swapped by the QuanserStream object to account for endian differences between the two endpoints of the connection. The QuanserStream object does not detect the endianness of the peer. Calling this method with the byteOrder argument set to ByteOrder.littleEndian causes the bytes to be swapped if the underlying platform is big endian. If the underlying platform is little endian then the bytes are not swapped. Calling this method with the byteOrder argument set to ByteOrder.bigEndian causes the bytes to be swapped if the underlying platform is little endian. If the underlying platform is big endian then the bytes are not swapped. Calling this method with the byteOrder argument set to ByteOrder.nativeEndian indicates that the bytes should not be swapped and the byte order of the underlying platform will be used. This byte order is the default. Byte swapping is only necessary when communicating between processors that use a different endianness. For example, Intel processors are little endian (LSB first) while Motorola processors tend to be big endian (MSB first). By default, no byte swapping takes place. Whether byte swapping is necessary may be determined simply by sending 0x1234 as a short and seeing if it arrives as the same number or 0x3421. Note that the SetSwapBytes and SetByteOrder methods override each other, so byte swapping will be determined by the last method called.
      Parameters:
      byteOrder - The byte order to use when sending and receive data over the stream.
      Throws:
      IOException - If the byte order cannot be configured then an exception is thrown. This situation should never occur unless the underlying stream has been closed.
    • setCharacterFormat

      public void setCharacterFormat(QuanserStream.CharacterFormat format) throws IOException
      Configures whether the methods that send and receive characters convert between the local character format and another character format when reading and writing to the underlying communication channel. This method may be used to cause the QuanserStream object to convert between character formats when sending and receiving characters (or arrays of characters). Character format conversions are only necessary when communicating between platforms that use a different character format. For example, Unix systems may use UTF-32 or UTF-8 wide characters while Windows uses UTF-16 wide characters. By default, the character format is assumed to be the same as the local character format.
      Parameters:
      format - The character format to use for the underlying communication channel. The local character format is converted to and from this format when communicating with the peer. If the format is set to CharacterFormat.auto then the stream will look for a Unicode BOM character as the first character received in order to determine the character format to use.
      Throws:
      IOException - If the character format cannot be configured then an exception is thrown. This situation should never occur unless the underlying stream has been closed.
    • getCharacterFormat

      public QuanserStream.CharacterFormat getCharacterFormat() throws IOException
      Returns the character format of the stream. Returns the character format of the stream. If the character format has not yet been determined then CharacterFormat.auto is returned. Otherwise the character format detected or set manually is returned. Character format conversions are only necessary when communicating between platforms that use a different character format. For example, Unix systems may use UTF-32 or UTF-8 wide characters while Windows uses UTF-16 wide characters. By default, the character format is assumed to be the same as the local character format.
      Returns:
      The character format in use for the underlying communication channel.
      Throws:
      IOException - If the character format cannot be determined then an exception is thrown. This situation should never occur unless the underlying stream has been closed.
    • poll

      public int poll(double timeout, int flags) throws IOException
      Polls the stream for events, such as whether it is possible to send or receive without blocking. This method polls the stream to determine whether it is possible to send, receive, accept a connection, or complete a connection without blocking. The flags argument determines the conditions for which to check. The return value indicates the conditions which occurred. This method returns after the given timeout with a value of 0 if none of the conditions occurs. If an error occurs, then it throws a IOException. The method will return before the timeout if at least one of the conditions occurs prior to the timeout.
      Parameters:
      timeout - A relative timeout value in seconds which determines the maximum time that this method will wait for one of the conditions to occur before returning.
      flags - A bit mask indicating the conditions for which to check. Combine one or more of the following flags using a bitwise-OR:
      • PollFlag.receive: On a listening stream, check for pending connections from clients. On a client stream, check whether there is any data available to receive.
      • PollFlag.send: Not valid on a listening stream. On a client stream, check whether there is any space in the stream buffer to store any data.
      • PollFlag.flush: Not valid on a listening stream. On a client stream, check whether it is possible to flush any more data without blocking.
      • PollFlag.accept: Not valid on a client stream. On a listening stream, check whether there is a pending client connection.
      • PollFlag.connect: Not valid on a listening stream. On a client stream, check whether the connection has completed.
      Returns:
      A bit mask containing the conditions which were satisfied. It has the same definition as the flags argument. If none of the specified conditions occurs before the timeout, then 0 is returned.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if one of the flags used is inconsistent with the type of stream or an error has occurred in the underlying communication channel.
    • ignore

      public int ignore(int numBytes) throws IOException
      Reads the specified number of bytes from the stream and discards them. This method receives data over a client stream. However this data is simply discarded. It is not returned to the caller. It attempts to receive numBytes bytes from the communication channel. If listen or connect was called with the non-blocking flag set to false, then this method blocks until all the data is read. If the connection has been closed gracefully then it returns 0 only once there is no more data to receive. Otherwise it returns the number of bytes read before the connection closed. Once all the data in the stream buffer is exhausted it will return 0 to indicate the connection has been closed. If an error occurs, then it throws a IOException. If listen or connect was called with the non-blocking flag set to true, then this method does not block. If no data is available at all then it returns -ErrorCode.WouldBlock. In this case, the poll(double, int) method may be used with the PollFlag.receive flag to determine when data becomes available. Otherwise it returns the number of bytes received. This method does not support two threads calling ignore or receive at the same time. However, send or flush may be called by another thread at the same time as ignore. The semantics of this method differ from the BSD recv() socket function because it receives numBytes bytes in blocking mode rather than the number of bytes that were sent in a single send() call at the peer. The semantics differ because this method attempts to "read ahead" by keeping the stream buffer full, thereby minimizing the number of receive operations performed on the internal connection. Also, due to buffering of the send operation, the number of send() calls made at the peer may not correspond to the number expected.
      Parameters:
      numBytes - The number of bytes to read from the stream and ignore.
      Returns:
      The number of bytes received, which may be less than numBytes bytes for non-blocking streams. If no more data is available and the connection has been closed gracefully then 0 is returned. If no bytes are received and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • receive

      public int receive(byte[] buffer) throws IOException
      Reads the specified number of 8-bit integers (i.e., bytes) from the stream. This method receives data over a client stream. It attempts to receive buffer.length 8-bit integers from the communication channel. If listen or connect was called with the non-blocking flag set to false, then this method blocks until all the data is read. If the connection has been closed gracefully then it returns 0 only once there is no more data to receive. Otherwise it returns the number of 8-bit integers read before the connection closed. Once all the data in the stream buffer is exhausted it will return 0 to indicate the connection has been closed. If an error occurs, then it throws a IOException. If listen or connect was called with the non-blocking flag set to true, then this method does not block. If no data is available at all then it returns -ErrorCode.WouldBlock. In this case, the poll(double, int) method may be used with the PollFlag.receive flag to determine when data becomes available. Otherwise it returns the number of 8-bit integers received. This method does not support two threads calling receive at the same time. However, send or flush() may be called by another thread at the same time as receive. The semantics of this method differ from the BSD recv() socket function because it receives buffer.length bytes in blocking mode rather than the number of bytes that were sent in a single send() call at the peer. The semantics differ because this method attempts to "read ahead" by keeping the stream buffer full, thereby minimizing the number of receive operations performed on the internal connection. Also, due to buffering of the send operation, the number of send() calls made at the peer may not correspond to the number expected. Unlike the receiveArray(byte[]) method, this method does not require that the internal stream receive buffer be as large as the array of 8-bit integers received. Hence, it allows smaller stream buffers to be used. The size of the stream receive buffer is set when the stream is created using the connect or accept method.
      Parameters:
      buffer - The buffer in which to store the values read. The length of this buffer determines the number of elements this method attempts to read. The number of elements read may be less than the number of elements in the buffer, so be sure to check the return value to see how many elements were actually read.
      Returns:
      The number of 8-bit integers received, which may be less than the number of elements in the buffer for non-blocking streams. If no more data is available and the connection has been closed gracefully then 0 is returned. If no 8-bit integers are received and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • receive

      public int receive(short[] buffer) throws IOException
      Reads the specified number of 16-bit integers (i.e., shorts) from the stream. This method receives data over a client stream. It attempts to receive buffer.length 16-bit integers from the communication channel. If the stream has been configured to swap bytes using the setSwapBytes(boolean) method then it will swap the order of the bytes within each 16-bit integer that it receives or sends. If listen or connect was called with the non-blocking flag set to false, then this method blocks until all the data is read. If listen or connect was called with the non-blocking flag set to true, then this method does not block. If fewer bytes are available than the size of a 16-bit integer then it returns -ErrorCode.WouldBlock. In this case, the poll(double, int) method may be used with the PollFlag.receive flag to determine when data becomes available. Otherwise it returns the number of 16-bit integers received. If the connection has been closed gracefully then it returns 0 only only if there are fewer bytes to receive than the size of a 16-bit integer. Otherwise it returns the number of 16-bit integers read before the connection closed. Once there are fewer bytes left to receive than the size of a 16-bit integer then it will return 0 to indicate the connection has been closed. Use receive(byte[]) to receive any remaining bytes if required. If an error occurs, then it throws a IOException. This method does not support two threads calling receive at the same time. However, send or flush() may be called by another thread at the same time as receive. The BSD socket API has no equivalent to this method. Unlike the receiveArray(short[]) method, this method does not require that the internal stream receive buffer be as large as the array of 16-bit integers received. Hence, it allows smaller stream buffers to be used. The size of the stream receive buffer is set when the stream is created using the connect or accept method.
      Parameters:
      buffer - The buffer in which to store the values read. The length of this buffer determines the number of elements this method attempts to read. The number of elements read may be less than the number of elements in the buffer, so be sure to check the return value to see how many elements were actually read.
      Returns:
      The number of 16-bit integers received, which may be less than the number of elements in the buffer for non-blocking streams. If fewer bytes are available than the size of a 16-bit integer and the connection has been closed gracefully then 0 is returned. If no 16-bit integers are received and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • receive

      public int receive(int[] buffer) throws IOException
      Reads the specified number of 32-bit integers (i.e., ints) from the stream. This method receives data over a client stream. It attempts to receive buffer.length 32-bit integers from the communication channel. If the stream has been configured to swap bytes using the setSwapBytes(boolean) method then it will swap the order of the bytes within each 64-bit floating-point number received or sent. If listen or connect was called with the non-blocking flag set to false, then this method blocks until all the data is read. If listen or connect was called with the non-blocking flag set to true, then this method does not block. If fewer bytes are available than the size of a 32-bit integer then it returns -ErrorCode.WouldBlock. In this case, the poll(double, int) method may be used with the PollFlag.receive flag to determine when data becomes available. Otherwise it returns the number of 32-bit integers received. If the connection has been closed gracefully then it returns 0 only only if there are fewer bytes to receive than the size of a 32-bit integer. Otherwise it returns the number of 32-bit integers read before the connection closed. Once there are fewer bytes left to receive than the size of a 32-bit integer then it will return 0 to indicate the connection has been closed. Use receive(byte[]) to receive any remaining bytes if required. If an error occurs, then it throws a IOException. This method does not support two threads calling receive at the same time. However, send or flush() may be called by another thread at the same time as receive. The BSD socket API has no equivalent to this method. Unlike the receiveArray(int[]) method, this method does not require that the internal stream receive buffer be as large as the array of 32-bit integers received. Hence, it allows smaller stream buffers to be used. The size of the stream receive buffer is set when the stream is created using the connect or accept method.
      Parameters:
      buffer - The buffer in which to store the values read. The length of this buffer determines the number of elements this method attempts to read. The number of elements read may be less than the number of elements in the buffer, so be sure to check the return value to see how many elements were actually read.
      Returns:
      The number of 32-bit integers received, which may be less than the number of elements in the buffer for non-blocking streams. If fewer bytes are available than the size of a 32-bit integer and the connection has been closed gracefully then 0 is returned. If no 32-bit integers are received and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • receive

      public int receive(long[] buffer) throws IOException
      Reads the specified number of 64-bit integers (i.e., longs) from the stream. This method receives data over a client stream. It attempts to receive buffer.length 64-bit integers from the communication channel. If the stream has been configured to swap bytes using the setSwapBytes(boolean) method then it will swap the order of the bytes within each 64-bit integer that it receives or sends. If listen or connect was called with the non-blocking flag set to false, then this method blocks until all the data is read. If listen or connect was called with the non-blocking flag set to true, then this method does not block. If fewer bytes are available than the size of a 64-bit integer then it returns -ErrorCode.WouldBlock. In this case, the poll(double, int) method may be used with the PollFlag.receive flag to determine when data becomes available. Otherwise it returns the number of 64-bit integers received. If the connection has been closed gracefully then it returns 0 only only if there are fewer bytes to receive than the size of a 64-bit integer. Otherwise it returns the number of 64-bit integers read before the connection closed. Once there are fewer bytes left to receive than the size of a 64-bit integer then it will return 0 to indicate the connection has been closed. Use receive(byte[]) to receive any remaining bytes if required. If an error occurs, then it throws a IOException. This method does not support two threads calling receive at the same time. However, send or flush() may be called by another thread at the same time as receive. The BSD socket API has no equivalent to this method. Unlike the receiveArray(long[]) method, this method does not require that the internal stream receive buffer be as large as the array of 32-bit integers received. Hence, it allows smaller stream buffers to be used. The size of the stream receive buffer is set when the stream is created using the connect or accept method.
      Parameters:
      buffer - The buffer in which to store the values read. The length of this buffer determines the number of elements this method attempts to read. The number of elements read may be less than the number of elements in the buffer, so be sure to check the return value to see how many elements were actually read.
      Returns:
      The number of 64-bit integers received, which may be less than the number of elements in the buffer for non-blocking streams. If fewer bytes are available than the size of a 64-bit integer and the connection has been closed gracefully then 0 is returned. If no 64-bit integers are received and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • receive

      public int receive(float[] buffer) throws IOException
      Reads the specified number of 32-bit, single-precision, floating-point numbers (i.e., floats) from the stream. This method receives data over a client stream. It attempts to receive buffer.length 32-bit, single-precision, floating-point numbers from the communication channel. If the stream has been configured to swap bytes using the setSwapBytes(boolean) method then it will swap the order of the bytes within each 32-bit floating-point number that it receives or sends. If listen or connect was called with the non-blocking flag set to false, then this method blocks until all the data is read. If listen or connect was called with the non-blocking flag set to true, then this method does not block. If fewer bytes are available than the size of a 32-bit floating-point number then it returns -ErrorCode.WouldBlock. In this case, the poll(double, int) method may be used with the PollFlag.receive flag to determine when data becomes available. Otherwise it returns the number of 32-bit floating-point numbers received. If the connection has been closed gracefully then it returns 0 only only if there are fewer bytes to receive than the size of a 32-bit floating-point number. Otherwise it returns the number of 32-bit floating-point numbers read before the connection closed. Once there are fewer bytes left to receive than the size of a 32-bit floating-point number then it will return 0 to indicate the connection has been closed. Use receive(byte[]) to receive any remaining bytes if required. If an error occurs, then it throws a IOException. This method does not support two threads calling receive at the same time. However, send or flush() may be called by another thread at the same time as receive. The BSD socket API has no equivalent to this method. Unlike the receiveArray(float[]) method, this method does not require that the internal stream receive buffer be as large as the array of 32-bit floating-point numbers received. Hence, it allows smaller stream buffers to be used. The size of the stream receive buffer is set when the stream is created using the connect or accept method.
      Parameters:
      buffer - The buffer in which to store the values read. The length of this buffer determines the number of elements this method attempts to read. The number of elements read may be less than the number of elements in the buffer, so be sure to check the return value to see how many elements were actually read.
      Returns:
      The number of 32-bit floating-point numbers received, which may be less than the number of elements in the buffer for non-blocking streams. If fewer bytes are available than the size of a 32-bit floating-point number and the connection has been closed gracefully then 0 is returned. If no 32-bit floating-point numbers are received and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • receive

      public int receive(double[] buffer) throws IOException
      Reads the specified number of 64-bit, double-precision, floating-point numbers (i.e., doubles) from the stream. This method receives data over a client stream. It attempts to receive buffer.length 64-bit, double-precision, floating-point numbers from the communication channel. If the stream has been configured to swap bytes using the setSwapBytes(boolean) method then it will swap the order of the bytes within each 64-bit floating-point number that it receives or sends. If listen or connect was called with the non-blocking flag set to false, then this method blocks until all the data is read. If listen or connect was called with the non-blocking flag set to true, then this method does not block. If fewer bytes are available than the size of a 64-bit floating-point number then it returns -ErrorCode.WouldBlock. In this case, the poll(double, int) method may be used with the PollFlag.receive flag to determine when data becomes available. Otherwise it returns the number of 64-bit floating-point numbers received. If the connection has been closed gracefully then it returns 0 only only if there are fewer bytes to receive than the size of a 64-bit floating-point number. Otherwise it returns the number of 64-bit floating-point numbers read before the connection closed. Once there are fewer bytes left to receive than the size of a 64-bit floating-point number then it will return 0 to indicate the connection has been closed. Use receive(byte[]) to receive any remaining bytes if required. If an error occurs, then it throws a IOException. This method does not support two threads calling receive at the same time. However, send or flush() may be called by another thread at the same time as receive. The BSD socket API has no equivalent to this method. Unlike the receiveArray(double[]) method, this method does not require that the internal stream receive buffer be as large as the array of 64-bit floating-point numbers received. Hence, it allows smaller stream buffers to be used. The size of the stream receive buffer is set when the stream is created using the connect or accept method.
      Parameters:
      buffer - The buffer in which to store the values read. The length of this buffer determines the number of elements this method attempts to read. The number of elements read may be less than the number of elements in the buffer, so be sure to check the return value to see how many elements were actually read.
      Returns:
      The number of 64-bit floating-point numbers received, which may be less than the number of elements in the buffer for non-blocking streams. If fewer bytes are available than the size of a 64-bit floating-point number and the connection has been closed gracefully then 0 is returned. If no 64-bit floating-point numbers are received and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • receiveArray

      public int receiveArray(byte[] buffer) throws IOException
      Reads an array of 8-bit integers (i.e., bytes) from the stream. This method receives an array of 8-bit integers over a client stream. It differs from the receive(byte[]) method in that it treats the entire array as an atomic unit. It either receives all of the array or none of it. This method is particularly useful for non-blocking streams because it ensures that all the values requested are read at one time. Unlike the receive(byte[]) method, the size of the stream receive buffer must be at least as large as the array of 8-bit integers being received. If listen or connect was called with the non-blocking flag set to false, then this method blocks until all the data is read. If listen or connect was called with the non-blocking flag set to true, then this method does not block. If fewer 8-bit integers are available than the size of the entire array then it returns -ErrorCode.WouldBlock. In this case, the poll(double, int) method may be used with the PollFlag.receive flag to determine when data becomes available. Otherwise it returns 1. If the connection has been closed gracefully then it returns 0 only if there are fewer 8-bit integers to receive than the size of the entire array. Otherwise it returns 1. Once there are fewer 8-bit integers left to receive than the size of the entire array then it will return 0 to indicate the connection has been closed. Use receive(byte[]) to receive any remaining bytes if required. If an error occurs, then it throws a IOException. This method does not support two threads calling receiveArray at the same time. However, sendArray or flush() may be called by another thread at the same time as receiveArray. The BSD socket API has no equivalent to this method.
      Parameters:
      buffer - The buffer in which to store the values read. The length of this buffer determines the number of elements this method attempts to read. The number of elements read may be less than the number of elements in the buffer or no elements will be read.
      Returns:
      Returns 1 on success. If not enough data is available and the connection has been closed gracefully then 0 is returned. If not enough 8-bit integers are received and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • receiveArray

      public int receiveArray(short[] buffer) throws IOException
      Reads an array of 16-bit integers (i.e., shorts) from the stream. This method receives an array of 16-bit integers over a client stream. It differs from the receive(short[]) method in that it treats the entire array as an atomic unit. It either receives all of the array or none of it. This method is particularly useful for non-blocking streams because it ensures that all the values requested are read at one time. If the stream has been configured to swap bytes using the setSwapBytes(boolean) method then it will swap the order of the bytes within each 16-bit integer sent or received. Unlike the receive(short[]) method, the size of the stream receive buffer must be at least as large as the array of 16-bit integers being received. If listen or connect was called with the non-blocking flag set to false, then this method blocks until all the data is read. If listen or connect was called with the non-blocking flag set to true, then this method does not block. If fewer 16-bit integers are available than the size of the entire array then it returns -ErrorCode.WouldBlock. In this case, the poll(double, int) method may be used with the PollFlag.receive flag to determine when data becomes available. Otherwise it returns 1. If the connection has been closed gracefully then it returns 0 only if there are fewer 16-bit integers to receive than the size of the entire array. Otherwise it returns 1. Once there are fewer 16-bit integers left to receive than the size of the entire array then it will return 0 to indicate the connection has been closed. Use receive(byte[]) to receive any remaining bytes if required. If an error occurs, then it throws a IOException. This method does not support two threads calling receiveArray at the same time. However, sendArray or flush() may be called by another thread at the same time as receiveArray. The BSD socket API has no equivalent to this method.
      Parameters:
      buffer - The buffer in which to store the values read. The length of this buffer determines the number of elements this method attempts to read. The number of elements read may be less than the number of elements in the buffer or no elements will be read.
      Returns:
      Returns 1 on success. If not enough data is available and the connection has been closed gracefully then 0 is returned. If not enough 16-bit integers are received and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • receiveArray

      public int receiveArray(int[] buffer) throws IOException
      Reads an array of 32-bit integers (i.e., ints) from the stream. This method receives an array of 32-bit integers over a client stream. It differs from the receive(int[]) method in that it treats the entire array as an atomic unit. It either receives all of the array or none of it. This method is particularly useful for non-blocking streams because it ensures that all the values requested are read at one time. If the stream has been configured to swap bytes using the setSwapBytes(boolean) method then it will swap the order of the bytes within each 32-bit floating-point number received or sent. Unlike the receive(int[]) method, the size of the stream receive buffer must be at least as large as the array of 32-bit integers being received. If listen or connect was called with the non-blocking flag set to false, then this method blocks until all the data is read. If listen or connect was called with the non-blocking flag set to true, then this method does not block. If fewer 32-bit integers are available than the size of the entire array then it returns -ErrorCode.WouldBlock. In this case, the poll(double, int) method may be used with the PollFlag.receive flag to determine when data becomes available. Otherwise it returns 1. If the connection has been closed gracefully then it returns 0 only if there are fewer 32-bit integers to receive than the size of the entire array. Otherwise it returns 1. Once there are fewer 32-bit integers left to receive than the size of the entire array then it will return 0 to indicate the connection has been closed. Use receive(byte[]) to receive any remaining bytes if required. If an error occurs, then it throws a IOException. This method does not support two threads calling receiveArray at the same time. However, sendArray or flush() may be called by another thread at the same time as receiveArray. The BSD socket API has no equivalent to this method.
      Parameters:
      buffer - The buffer in which to store the values read. The length of this buffer determines the number of elements this method attempts to read. The number of elements read may be less than the number of elements in the buffer or no elements will be read.
      Returns:
      Returns 1 on success. If not enough data is available and the connection has been closed gracefully then 0 is returned. If not enough 32-bit integers are received and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • receiveArray

      public int receiveArray(long[] buffer) throws IOException
      Reads an array of 64-bit integers (i.e., longs) from the stream. This method receives an array of 64-bit integers over a client stream. It differs from the receive(int[]) method in that it treats the entire array as an atomic unit. It either receives all of the array or none of it. This method is particularly useful for non-blocking streams because it ensures that all the values requested are read at one time. If the stream has been configured to swap bytes using the setSwapBytes(boolean) method then it will swap the order of the bytes within each 64-bit integer received or sent. Unlike the receive(int[]) method, the size of the stream receive buffer must be at least as large as the array of 64-bit integers being received. If listen or connect was called with the non-blocking flag set to false, then this method blocks until all the data is read. If listen or connect was called with the non-blocking flag set to true, then this method does not block. If fewer 64-bit integers are available than the size of the entire array then it returns -ErrorCode.WouldBlock. In this case, the poll(double, int) method may be used with the PollFlag.receive flag to determine when data becomes available. Otherwise it returns 1. If the connection has been closed gracefully then it returns 0 only if there are fewer 64-bit integers to receive than the size of the entire array. Otherwise it returns 1. Once there are fewer 64-bit integers left to receive than the size of the entire array then it will return 0 to indicate the connection has been closed. Use receive(byte[]) to receive any remaining bytes if required. If an error occurs, then it throws a IOException. This method does not support two threads calling receiveArray at the same time. However, sendArray or flush() may be called by another thread at the same time as receiveArray. The BSD socket API has no equivalent to this method.
      Parameters:
      buffer - The buffer in which to store the values read. The length of this buffer determines the number of elements this method attempts to read. The number of elements read may be less than the number of elements in the buffer or no elements will be read.
      Returns:
      Returns 1 on success. If not enough data is available and the connection has been closed gracefully then 0 is returned. If not enough 64-bit integers are received and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • receiveArray

      public int receiveArray(float[] buffer) throws IOException
      Reads an array of 32-bit, single-precision, floating-point numbers (i.e., floats) from the stream. This method receives an array of 32-bit, single-precision, floating-point numbers over a client stream. It differs from the receive(float[]) method in that it treats the entire array as an atomic unit. It either receives all of the array or none of it. This method is particularly useful for non-blocking streams because it ensures that all the values requested are read at one time. If the stream has been configured to swap bytes using the setSwapBytes(boolean) method then it will swap the order of the bytes within each 32-bit floating-point number received or sent. Unlike the receive(float[]) method, the size of the stream receive buffer must be at least as large as the array of 32-bit floating-point numbers being received. If listen or connect was called with the non-blocking flag set to false, then this method blocks until all the data is read. If listen or connect was called with the non-blocking flag set to true, then this method does not block. If fewer 32-bit floating-point numbers are available than the size of the entire array then it returns -ErrorCode.WouldBlock. In this case, the poll(double, int) method may be used with the PollFlag.receive flag to determine when data becomes available. Otherwise it returns 1. If the connection has been closed gracefully then it returns 0 only if there are fewer 32-bit floating-point numbers to receive than the size of the entire array. Otherwise it returns 1. Once there are fewer 32-bit floating-point numbers left to receive than the size of the entire array then it will return 0 to indicate the connection has been closed. Use receive(byte[]) to receive any remaining bytes if required. If an error occurs, then it throws a IOException. This method does not support two threads calling receiveArray at the same time. However, sendArray or flush() may be called by another thread at the same time as receiveArray. The BSD socket API has no equivalent to this method.
      Parameters:
      buffer - The buffer in which to store the values read. The length of this buffer determines the number of elements this method attempts to read. The number of elements read may be less than the number of elements in the buffer or no elements will be read.
      Returns:
      Returns 1 on success. If not enough data is available and the connection has been closed gracefully then 0 is returned. If not enough 32-bit floating-point numbers are received and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • receiveArray

      public int receiveArray(double[] buffer) throws IOException
      Reads an array of 64-bit, double-precision, floating-point numbers (i.e., doubles) from the stream. This method receives an array of 64-bit, double-precision, floating-point numbers over a client stream. It differs from the receive(double[]) method in that it treats the entire array as an atomic unit. It either receives all of the array or none of it. This method is particularly useful for non-blocking streams because it ensures that all the values requested are read at one time. If the stream has been configured to swap bytes using the setSwapBytes(boolean) method then it will swap the order of the bytes within each 64-bit floating-point number received or sent. Unlike the receive(float[]) method, the size of the stream receive buffer must be at least as large as the array of 64-bit floating-point numbers being received. If listen or connect was called with the non-blocking flag set to false, then this method blocks until all the data is read. If listen or connect was called with the non-blocking flag set to true, then this method does not block. If fewer 64-bit floating-point numbers are available than the size of the entire array then it returns -ErrorCode.WouldBlock. In this case, the poll(double, int) method may be used with the PollFlag.receive flag to determine when data becomes available. Otherwise it returns 1. If the connection has been closed gracefully then it returns 0 only if there are fewer 64-bit floating-point numbers to receive than the size of the entire array. Otherwise it returns 1. Once there are fewer 64-bit floating-point numbers left to receive than the size of the entire array then it will return 0 to indicate the connection has been closed. Use receive(byte[]) to receive any remaining bytes if required. If an error occurs, then it throws a IOException. This method does not support two threads calling receiveArray at the same time. However, sendArray or flush() may be called by another thread at the same time as receiveArray. The BSD socket API has no equivalent to this method.
      Parameters:
      buffer - The buffer in which to store the values read. The length of this buffer determines the number of elements this method attempts to read. The number of elements read may be less than the number of elements in the buffer or no elements will be read.
      Returns:
      Returns 1 on success. If not enough data is available and the connection has been closed gracefully then 0 is returned. If not enough 64-bit floating-point numbers are received and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • send

      public int send(byte[] buffer) throws IOException
      Writes the specified number of 8-bit integers (i.e., bytes) to the stream send buffer. This method writes data to the stream send buffer. It attempts to store buffer.length 8-bit integers in the internal stream buffer. If there is enough room available in the stream buffer then it stores the data in the buffer and returns immediately. The data is not written to the actual communication channel until the stream is flushed using flush() or there is no more room available in the stream buffer. If an error occurs, then it throws a IOException. If the connection is closed it is considered an error condition. If listen or connect was called with the non-blocking flag set to false, then this method may block attempting to flush the stream buffer. All the data will be consumed and the total number of 8-bit integers sent is returned. Some of the data may remain in the stream buffer and not be sent until the next time flush() is called or there is no more room available in the stream buffer. If an error occurs then the a IOException is thrown and the stream should be closed. If listen or connect was called with the non-blocking flag set to true, then this method does not block. It returns the number of 8-bit integers sent successfully, which will be between 1 and buffer.length (unless the buffer has zero length). If no 8-bit integers could be sent without blocking, then -ErrorCode.WouldBlock is returned. In this case, the poll(double, int) method may be used with the PollFlag.send flag to determine when space in the buffer becomes available. If an error occurs then a IOException is thrown and the stream should be closed. This method does not support two threads calling send or flush() at the same time. However, receive may be called by another thread at the same time as send. The semantics of this method are comparable to the BSD send() socket function. Unlike the sendArray(byte[]) method, this method does not require that the internal stream send buffer be as large as the array of 8-bit integers to be sent. Hence, it allows smaller stream buffers to be used. The size of the stream receive buffer is set when the stream is created using the connect or accept method.
      Parameters:
      buffer - The buffer containing the values to write. The length of this buffer determines the number of elements this method attempts to send. The number of elements written may be less than the number of elements in the buffer, so be sure to check the return value to see how many elements were actually written.
      Returns:
      The number of 8-bit integers written, which may be less than the number of elements in the buffer for non-blocking streams. If no 8-bit integers could be written to the stream buffer and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • send

      public int send(short[] buffer) throws IOException
      Writes the specified number of 16-bit integers (i.e., shorts) to the stream send buffer. This method writes data to the stream send buffer. It attempts to store buffer.length 16-bit integers in the internal stream buffer. If there is enough room available in the stream buffer then it stores the data in the buffer and returns immediately. The data is not written to the actual communication channel until the stream is flushed using flush() or there is no more room available in the stream buffer. If an error occurs, then it throws a IOException. If the connection is closed it is considered an error condition. If the stream has been configured to swap bytes using the setSwapBytes(boolean) method then this function will swap the order of the bytes within each 16-bit integer when they are sent. If listen or connect was called with the non-blocking flag set to false, then this method may block attempting to flush the stream buffer. All the data will be consumed and the total number of 16-bit integers sent is returned. Some of the data may remain in the stream buffer and not be sent until the next time flush() is called or there is no more room available in the stream buffer. If an error occurs then the a IOException is thrown and the stream should be closed. If listen or connect was called with the non-blocking flag set to true, then this method does not block. It returns the number of 16-bit integers sent successfully, which will be between 1 and buffer.length (unless the buffer has zero length). If no 16-bit integers could be sent without blocking, then -ErrorCode.WouldBlock is returned. In this case, the poll(double, int) method may be used with the PollFlag.send flag to determine when space in the buffer becomes available. If an error occurs then a IOException is thrown and the stream should be closed. This method does not support two threads calling send or flush() at the same time. However, receive may be called by another thread at the same time as send. The BSD socket API has no equivalent to this method. Unlike the sendArray(short[]) method, this method does not require that the internal stream send buffer be as large as the array of 16-bit integers to be sent. Hence, it allows smaller stream buffers to be used. The size of the stream receive buffer is set when the stream is created using the connect or accept method.
      Parameters:
      buffer - The buffer containing the values to write. The length of this buffer determines the number of elements this method attempts to send. The number of elements written may be less than the number of elements in the buffer, so be sure to check the return value to see how many elements were actually written.
      Returns:
      The number of 16-bit integers written, which may be less than the number of elements in the buffer for non-blocking streams. If no 16-bit integers could be written to the stream buffer and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • send

      public int send(int[] buffer) throws IOException
      Writes the specified number of 32-bit integers (i.e., ints) to the stream send buffer. This method writes data to the stream send buffer. It attempts to store buffer.length 32-bit integers in the internal stream buffer. If there is enough room available in the stream buffer then it stores the data in the buffer and returns immediately. The data is not written to the actual communication channel until the stream is flushed using flush() or there is no more room available in the stream buffer. If an error occurs, then it throws a IOException. If the connection is closed it is considered an error condition. If the stream has been configured to swap bytes using the setSwapBytes(boolean) method then this function will swap the order of the bytes within each 32-bit integer when they are sent. If listen or connect was called with the non-blocking flag set to false, then this method may block attempting to flush the stream buffer. All the data will be consumed and the total number of 32-bit integers sent is returned. Some of the data may remain in the stream buffer and not be sent until the next time flush() is called or there is no more room available in the stream buffer. If an error occurs then the a IOException is thrown and the stream should be closed. If listen or connect was called with the non-blocking flag set to true, then this method does not block. It returns the number of 32-bit integers sent successfully, which will be between 1 and buffer.length (unless the buffer has zero length). If no 32-bit integers could be sent without blocking, then -ErrorCode.WouldBlock is returned. In this case, the poll(double, int) method may be used with the PollFlag.send flag to determine when space in the buffer becomes available. If an error occurs then a IOException is thrown and the stream should be closed. This method does not support two threads calling send or flush() at the same time. However, receive may be called by another thread at the same time as send. The BSD socket API has no equivalent to this method. Unlike the sendArray(int[]) method, this method does not require that the internal stream send buffer be as large as the array of 32-bit integers to be sent. Hence, it allows smaller stream buffers to be used. The size of the stream receive buffer is set when the stream is created using the connect or accept method.
      Parameters:
      buffer - The buffer containing the values to write. The length of this buffer determines the number of elements this method attempts to send. The number of elements written may be less than the number of elements in the buffer, so be sure to check the return value to see how many elements were actually written.
      Returns:
      The number of 32-bit integers written, which may be less than the number of elements in the buffer for non-blocking streams. If no 32-bit integers could be written to the stream buffer and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • send

      public int send(long[] buffer) throws IOException
      Writes the specified number of 64-bit integers (i.e., longs) to the stream send buffer. This method writes data to the stream send buffer. It attempts to store buffer.length 64-bit integers in the internal stream buffer. If there is enough room available in the stream buffer then it stores the data in the buffer and returns immediately. The data is not written to the actual communication channel until the stream is flushed using flush() or there is no more room available in the stream buffer. If an error occurs, then it throws a IOException. If the connection is closed it is considered an error condition. If the stream has been configured to swap bytes using the setSwapBytes(boolean) method then this function will swap the order of the bytes within each 64-bit integer when they are sent. If listen or connect was called with the non-blocking flag set to false, then this method may block attempting to flush the stream buffer. All the data will be consumed and the total number of 32-bit integers sent is returned. Some of the data may remain in the stream buffer and not be sent until the next time flush() is called or there is no more room available in the stream buffer. If an error occurs then the a IOException is thrown and the stream should be closed. If listen or connect was called with the non-blocking flag set to true, then this method does not block. It returns the number of 64-bit integers sent successfully, which will be between 1 and buffer.length (unless the buffer has zero length). If no 64-bit integers could be sent without blocking, then -ErrorCode.WouldBlock is returned. In this case, the poll(double, int) method may be used with the PollFlag.send flag to determine when space in the buffer becomes available. If an error occurs then a IOException is thrown and the stream should be closed. This method does not support two threads calling send or flush() at the same time. However, receive may be called by another thread at the same time as send. The BSD socket API has no equivalent to this method. Unlike the sendArray(long[]) method, this method does not require that the internal stream send buffer be as large as the array of 64-bit integers to be sent. Hence, it allows smaller stream buffers to be used. The size of the stream receive buffer is set when the stream is created using the connect or accept method.
      Parameters:
      buffer - The buffer containing the values to write. The length of this buffer determines the number of elements this method attempts to send. The number of elements written may be less than the number of elements in the buffer, so be sure to check the return value to see how many elements were actually written.
      Returns:
      The number of 64-bit integers written, which may be less than the number of elements in the buffer for non-blocking streams. If no 32-bit integers could be written to the stream buffer and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • send

      public int send(float[] buffer) throws IOException
      Writes the specified number of 32-bit, single-precision, floating-point (i.e., floats) to the stream send buffer. This method writes data to the stream send buffer. It attempts to store buffer.length 32-bit, single-precision, floating-point numbers in the internal stream buffer. If there is enough room available in the stream buffer then it stores the data in the buffer and returns immediately. The data is not written to the actual communication channel until the stream is flushed using flush() or there is no more room available in the stream buffer. If an error occurs, then it throws a IOException. If the connection is closed it is considered an error condition. If the stream has been configured to swap bytes using the setSwapBytes(boolean) method then this function will swap the order of the bytes within each 32-bit floating-point number when they are sent. If listen or connect was called with the non-blocking flag set to false, then this method may block attempting to flush the stream buffer. All the data will be consumed and the total number of 32-bit floating-point number sent is returned. Some of the data may remain in the stream buffer and not be sent until the next time flush() is called or there is no more room available in the stream buffer. If an error occurs then the a IOException is thrown and the stream should be closed. If listen or connect was called with the non-blocking flag set to true, then this method does not block. It returns the number of 32-bit floating-point numbers sent successfully, which will be between 1 and buffer.length (unless the buffer has zero length). If no 32-bit floating-point numbers could be sent without blocking, then -ErrorCode.WouldBlock is returned. In this case, the poll(double, int) method may be used with the PollFlag.send flag to determine when space in the buffer becomes available. If an error occurs then a IOException is thrown and the stream should be closed. This method does not support two threads calling send or flush() at the same time. However, receive may be called by another thread at the same time as send. The BSD socket API has no equivalent to this method. Unlike the sendArray(float[]) method, this method does not require that the internal stream send buffer be as large as the array of 32-bit floating-point numbers to be sent. Hence, it allows smaller stream buffers to be used. The size of the stream receive buffer is set when the stream is created using the connect or accept method.
      Parameters:
      buffer - The buffer containing the values to write. The length of this buffer determines the number of elements this method attempts to send. The number of elements written may be less than the number of elements in the buffer, so be sure to check the return value to see how many elements were actually written.
      Returns:
      The number of 32-bit floating-point numbers written, which may be less than the number of elements in the buffer for non-blocking streams. If no 32-bit floating-point numbers could be written to the stream buffer and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • send

      public int send(double[] buffer) throws IOException
      Writes the specified number of 64-bit, double-precision, floating-point (i.e., doubles) to the stream send buffer. This method writes data to the stream send buffer. It attempts to store buffer.length 64-bit, double-precision, floating-point numbers in the internal stream buffer. If there is enough room available in the stream buffer then it stores the data in the buffer and returns immediately. The data is not written to the actual communication channel until the stream is flushed using flush() or there is no more room available in the stream buffer. If an error occurs, then it throws a IOException. If the connection is closed it is considered an error condition. If the stream has been configured to swap bytes using the setSwapBytes(boolean) method then this function will swap the order of the bytes within each 64-bit floating-point number when they are sent. If listen or connect was called with the non-blocking flag set to false, then this method may block attempting to flush the stream buffer. All the data will be consumed and the total number of 64-bit floating-point number sent is returned. Some of the data may remain in the stream buffer and not be sent until the next time flush() is called or there is no more room available in the stream buffer. If an error occurs then the a IOException is thrown and the stream should be closed. If listen or connect was called with the non-blocking flag set to true, then this method does not block. It returns the number of 64-bit floating-point numbers sent successfully, which will be between 1 and buffer.length (unless the buffer has zero length). If no 64-bit floating-point numbers could be sent without blocking, then -ErrorCode.WouldBlock is returned. In this case, the poll(double, int) method may be used with the PollFlag.send flag to determine when space in the buffer becomes available. If an error occurs then a IOException is thrown and the stream should be closed. This method does not support two threads calling send or flush() at the same time. However, receive may be called by another thread at the same time as send. The BSD socket API has no equivalent to this method. Unlike the sendArray(double[]) method, this method does not require that the internal stream send buffer be as large as the array of 64-bit floating-point numbers to be sent. Hence, it allows smaller stream buffers to be used. The size of the stream receive buffer is set when the stream is created using the connect or accept method.
      Parameters:
      buffer - The buffer containing the values to write. The length of this buffer determines the number of elements this method attempts to send. The number of elements written may be less than the number of elements in the buffer, so be sure to check the return value to see how many elements were actually written.
      Returns:
      The number of 64-bit floating-point numbers written, which may be less than the number of elements in the buffer for non-blocking streams. If no 64-bit floating-point numbers could be written to the stream buffer and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • sendArray

      public int sendArray(byte[] buffer) throws IOException
      Writes the specified array of 8-bit integers (i.e., bytes) to the stream send buffer. This method writes data to the stream send buffer. It attempts to store buffer.length 8-bit integers in the internal stream buffer. It differs from the send(byte[]) method in that it treats the entire array as an atomic unit. It either writes all of the array or none of it. If there is enough room available in the stream buffer then it stores the data in the buffer and returns immediately. The data is not written to the actual communication channel until the stream is flushed using flush() or there is no more room available in the stream buffer. If an error occurs, then it throws a IOException. If the connection is closed it is considered an error condition. This method is particularly useful for non-blocking streams because it ensures that all the values requested are written at one time. Unlike the send(byte[]) method, the size of the stream send buffer must be at least as large as the number of 8-bit integers sent. The size of the stream send buffer is set when the stream is created using the connect or accept method. If listen or connect was called with the non-blocking flag set to false, then this method may block attempting to flush the stream buffer. All the data will be consumed and 1 is returned. Some of the data may remain in the stream buffer and not be sent until the next time flush() is called or there is no more room available in the stream buffer. If an error occurs then the a IOException is thrown and the stream should be closed. If listen or connect was called with the non-blocking flag set to true, then this method does not block. It returns 1 if the entire array is sent successfully. If the entire array could not be sent without blocking, then -ErrorCode.WouldBlock is returned. In this case, the poll(double, int) method may be used with the PollFlag.send flag to determine when space in the buffer becomes available. If an error occurs then a IOException is thrown and the stream should be closed. This method does not support two threads calling send or flush() at the same time. However, receive may be called by another thread at the same time as send. The BSD socket API has no equivalent to this method.
      Parameters:
      buffer - The buffer containing the values to write. The length of this buffer determines the number of elements this method attempts to send. The number of elements written is always equal to the length of this buffer if the data is sent successfully. This method never sends part of the array. It sends all of it or none of it.
      Returns:
      Returns 1 on success. If the entire array could not be written to the stream buffer and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • sendArray

      public int sendArray(short[] buffer) throws IOException
      Writes the specified array of 16-bit integers (i.e., shorts) to the stream send buffer. This method writes data to the stream send buffer. It attempts to store buffer.length 16-bit integers in the internal stream buffer. It differs from the send(short[]) method in that it treats the entire array as an atomic unit. It either writes all of the array or none of it. If there is enough room available in the stream buffer then it stores the data in the buffer and returns immediately. The data is not written to the actual communication channel until the stream is flushed using flush() or there is no more room available in the stream buffer. If an error occurs, then it throws a IOException. If the connection is closed it is considered an error condition. This method is particularly useful for non-blocking streams because it ensures that all the values requested are written at one time. Unlike the send(short[]) method, the size of the stream send buffer must be at least as large as the number of 16-bit integers sent. The size of the stream send buffer is set when the stream is created using the connect or accept method. If listen or connect was called with the non-blocking flag set to false, then this method may block attempting to flush the stream buffer. All the data will be consumed and 1 is returned. Some of the data may remain in the stream buffer and not be sent until the next time flush() is called or there is no more room available in the stream buffer. If an error occurs then the a IOException is thrown and the stream should be closed. If listen or connect was called with the non-blocking flag set to true, then this method does not block. It returns 1 if the entire array is sent successfully. If the entire array could not be sent without blocking, then -ErrorCode.WouldBlock is returned. In this case, the poll(double, int) method may be used with the PollFlag.send flag to determine when space in the buffer becomes available. If an error occurs then a IOException is thrown and the stream should be closed. This method does not support two threads calling send or flush() at the same time. However, receive may be called by another thread at the same time as send. The BSD socket API has no equivalent to this method.
      Parameters:
      buffer - The buffer containing the values to write. The length of this buffer determines the number of elements this method attempts to send. The number of elements written is always equal to the length of this buffer if the data is sent successfully. This method never sends part of the array. It sends all of it or none of it.
      Returns:
      Returns 1 on success. If the entire array could not be written to the stream buffer and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • sendArray

      public int sendArray(int[] buffer) throws IOException
      Writes the specified array of 32-bit integers (i.e., ints) to the stream send buffer. This method writes data to the stream send buffer. It attempts to store buffer.length 32-bit integers in the internal stream buffer. It differs from the send(int[]) method in that it treats the entire array as an atomic unit. It either writes all of the array or none of it. If there is enough room available in the stream buffer then it stores the data in the buffer and returns immediately. The data is not written to the actual communication channel until the stream is flushed using flush() or there is no more room available in the stream buffer. If an error occurs, then it throws a IOException. If the connection is closed it is considered an error condition. This method is particularly useful for non-blocking streams because it ensures that all the values requested are written at one time. Unlike the send(int[]) method, the size of the stream send buffer must be at least as large as the number of 32-bit integers sent. The size of the stream send buffer is set when the stream is created using the connect or accept method. If listen or connect was called with the non-blocking flag set to false, then this method may block attempting to flush the stream buffer. All the data will be consumed and 1 is returned. Some of the data may remain in the stream buffer and not be sent until the next time flush() is called or there is no more room available in the stream buffer. If an error occurs then the a IOException is thrown and the stream should be closed. If listen or connect was called with the non-blocking flag set to true, then this method does not block. It returns 1 if the entire array is sent successfully. If the entire array could not be sent without blocking, then -ErrorCode.WouldBlock is returned. In this case, the poll(double, int) method may be used with the PollFlag.send flag to determine when space in the buffer becomes available. If an error occurs then a IOException is thrown and the stream should be closed. This method does not support two threads calling send or flush() at the same time. However, receive may be called by another thread at the same time as send. The BSD socket API has no equivalent to this method.
      Parameters:
      buffer - The buffer containing the values to write. The length of this buffer determines the number of elements this method attempts to send. The number of elements written is always equal to the length of this buffer if the data is sent successfully. This method never sends part of the array. It sends all of it or none of it.
      Returns:
      Returns 1 on success. If the entire array could not be written to the stream buffer and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • sendArray

      public int sendArray(long[] buffer) throws IOException
      Writes the specified array of 64-bit integers (i.e., longs) to the stream send buffer. This method writes data to the stream send buffer. It attempts to store buffer.length 64-bit integers in the internal stream buffer. It differs from the send(long[]) method in that it treats the entire array as an atomic unit. It either writes all of the array or none of it. If there is enough room available in the stream buffer then it stores the data in the buffer and returns immediately. The data is not written to the actual communication channel until the stream is flushed using flush() or there is no more room available in the stream buffer. If an error occurs, then it throws a IOException. If the connection is closed it is considered an error condition. This method is particularly useful for non-blocking streams because it ensures that all the values requested are written at one time. Unlike the send(long[]) method, the size of the stream send buffer must be at least as large as the number of 64-bit integers sent. The size of the stream send buffer is set when the stream is created using the connect or accept method. If listen or connect was called with the non-blocking flag set to false, then this method may block attempting to flush the stream buffer. All the data will be consumed and 1 is returned. Some of the data may remain in the stream buffer and not be sent until the next time flush() is called or there is no more room available in the stream buffer. If an error occurs then the a IOException is thrown and the stream should be closed. If listen or connect was called with the non-blocking flag set to true, then this method does not block. It returns 1 if the entire array is sent successfully. If the entire array could not be sent without blocking, then -ErrorCode.WouldBlock is returned. In this case, the poll(double, int) method may be used with the PollFlag.send flag to determine when space in the buffer becomes available. If an error occurs then a IOException is thrown and the stream should be closed. This method does not support two threads calling send or flush() at the same time. However, receive may be called by another thread at the same time as send. The BSD socket API has no equivalent to this method.
      Parameters:
      buffer - The buffer containing the values to write. The length of this buffer determines the number of elements this method attempts to send. The number of elements written is always equal to the length of this buffer if the data is sent successfully. This method never sends part of the array. It sends all of it or none of it.
      Returns:
      Returns 1 on success. If the entire array could not be written to the stream buffer and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • sendArray

      public int sendArray(float[] buffer) throws IOException
      Writes the specified array of 32-bit, single-precision, floating-point numbers (i.e., floats) to the stream send buffer. This method writes data to the stream send buffer. It attempts to store buffer.length 32-bit, single-precision, floating-point numbers in the internal stream buffer. It differs from the send(float[]) method in that it treats the entire array as an atomic unit. It either writes all of the array or none of it. If there is enough room available in the stream buffer then it stores the data in the buffer and returns immediately. The data is not written to the actual communication channel until the stream is flushed using flush() or there is no more room available in the stream buffer. If an error occurs, then it throws a IOException. If the connection is closed it is considered an error condition. This method is particularly useful for non-blocking streams because it ensures that all the values requested are written at one time. Unlike the send(float[]) method, the size of the stream send buffer must be at least as large as the number of 32-bit floating-point numbers sent. The size of the stream send buffer is set when the stream is created using the connect or accept method. If listen or connect was called with the non-blocking flag set to false, then this method may block attempting to flush the stream buffer. All the data will be consumed and 1 is returned. Some of the data may remain in the stream buffer and not be sent until the next time flush() is called or there is no more room available in the stream buffer. If an error occurs then the a IOException is thrown and the stream should be closed. If listen or connect was called with the non-blocking flag set to true, then this method does not block. It returns 1 if the entire array is sent successfully. If the entire array could not be sent without blocking, then -ErrorCode.WouldBlock is returned. In this case, the poll(double, int) method may be used with the PollFlag.send flag to determine when space in the buffer becomes available. If an error occurs then a IOException is thrown and the stream should be closed. This method does not support two threads calling send or flush() at the same time. However, receive may be called by another thread at the same time as send. The BSD socket API has no equivalent to this method.
      Parameters:
      buffer - The buffer containing the values to write. The length of this buffer determines the number of elements this method attempts to send. The number of elements written is always equal to the length of this buffer if the data is sent successfully. This method never sends part of the array. It sends all of it or none of it.
      Returns:
      Returns 1 on success. If the entire array could not be written to the stream buffer and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • sendArray

      public int sendArray(double[] buffer) throws IOException
      Writes the specified array of 64-bit, double-precision, floating-point numbers (i.e., doubles) to the stream send buffer. This method writes data to the stream send buffer. It attempts to store buffer.length 64-bit, double-precision, floating-point numbers in the internal stream buffer. It differs from the send(double[]) method in that it treats the entire array as an atomic unit. It either writes all of the array or none of it. If there is enough room available in the stream buffer then it stores the data in the buffer and returns immediately. The data is not written to the actual communication channel until the stream is flushed using flush() or there is no more room available in the stream buffer. If an error occurs, then it throws a IOException. If the connection is closed it is considered an error condition. This method is particularly useful for non-blocking streams because it ensures that all the values requested are written at one time. Unlike the send(double[]) method, the size of the stream send buffer must be at least as large as the number of 64-bit floating-point numbers sent. The size of the stream send buffer is set when the stream is created using the connect or accept method. If listen or connect was called with the non-blocking flag set to false, then this method may block attempting to flush the stream buffer. All the data will be consumed and 1 is returned. Some of the data may remain in the stream buffer and not be sent until the next time flush() is called or there is no more room available in the stream buffer. If an error occurs then the a IOException is thrown and the stream should be closed. If listen or connect was called with the non-blocking flag set to true, then this method does not block. It returns 1 if the entire array is sent successfully. If the entire array could not be sent without blocking, then -ErrorCode.WouldBlock is returned. In this case, the poll(double, int) method may be used with the PollFlag.send flag to determine when space in the buffer becomes available. If an error occurs then a IOException is thrown and the stream should be closed. This method does not support two threads calling send or flush() at the same time. However, receive may be called by another thread at the same time as send. The BSD socket API has no equivalent to this method.
      Parameters:
      buffer - The buffer containing the values to write. The length of this buffer determines the number of elements this method attempts to send. The number of elements written is always equal to the length of this buffer if the data is sent successfully. This method never sends part of the array. It sends all of it or none of it.
      Returns:
      Returns 1 on success. If the entire array could not be written to the stream buffer and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • sendByte

      public int sendByte(byte value) throws IOException
      Writes a single 8-bit integer (i.e., byte) to the stream send buffer. This method writes data to the stream send buffer. It attempts to store one 8-bit integer in the internal stream buffer. If there is enough room available in the stream buffer then it stores the data in the buffer and returns immediately. The data is not written to the actual communication channel until the stream is flushed using flush() or there is no more room available in the stream buffer. If an error occurs, then it throws a IOException. If the connection is closed it is considered an error condition. If listen or connect was called with the non-blocking flag set to false, then this method may block attempting to flush the stream buffer. All the data will be consumed and the total number of 8-bit integers sent is returned, which will be always be 1. Some of the data may remain in the stream buffer and not be sent until the next time flush() is called or there is no more room available in the stream buffer. If an error occurs then the a IOException is thrown and the stream should be closed. If listen or connect was called with the non-blocking flag set to true, then this method does not block. It returns the number of 8-bit integers sent successfully, which will be always be 1. If no 8-bit integers could be sent without blocking, then -ErrorCode.WouldBlock is returned. In this case, the poll(double, int) method may be used with the PollFlag.send flag to determine when space in the buffer becomes available. If an error occurs then a IOException is thrown and the stream should be closed. This method does not support two threads calling send or flush() at the same time. However, receive may be called by another thread at the same time as send.
      Parameters:
      value - The value to write.
      Returns:
      The number of 8-bit integers written, which will always be 1. If no 8-bit integers could be written to the stream buffer and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • sendShort

      public int sendShort(short value) throws IOException
      Writes a single 16-bit integer (i.e., short) to the stream send buffer. This method writes data to the stream send buffer. It attempts to store one 16-bit integer in the internal stream buffer. If there is enough room available in the stream buffer then it stores the data in the buffer and returns immediately. The data is not written to the actual communication channel until the stream is flushed using flush() or there is no more room available in the stream buffer. If an error occurs, then it throws a IOException. If the connection is closed it is considered an error condition. If the stream has been configured to swap bytes using the setSwapBytes(boolean) method then this function will swap the order of the bytes within each 16-bit integer when they are sent. If listen or connect was called with the non-blocking flag set to false, then this method may block attempting to flush the stream buffer. All the data will be consumed and the total number of 16-bit integers sent is returned, which will be always be 1. Some of the data may remain in the stream buffer and not be sent until the next time flush() is called or there is no more room available in the stream buffer. If an error occurs then the a IOException is thrown and the stream should be closed. If listen or connect was called with the non-blocking flag set to true, then this method does not block. It returns the number of 16-bit integers sent successfully, which will be always be 1. If no 8-bit integers could be sent without blocking, then -ErrorCode.WouldBlock is returned. In this case, the poll(double, int) method may be used with the PollFlag.send flag to determine when space in the buffer becomes available. If an error occurs then a IOException is thrown and the stream should be closed. This method does not support two threads calling send or flush() at the same time. However, receive may be called by another thread at the same time as send.
      Parameters:
      value - The value to write.
      Returns:
      The number of 16-bit integers written, which will always be 1. If no 16-bit integers could be written to the stream buffer and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • sendInt

      public int sendInt(int value) throws IOException
      Writes a single 32-bit integer (i.e., int) to the stream send buffer. This method writes data to the stream send buffer. It attempts to store one 32-bit integer in the internal stream buffer. If there is enough room available in the stream buffer then it stores the data in the buffer and returns immediately. The data is not written to the actual communication channel until the stream is flushed using flush() or there is no more room available in the stream buffer. If an error occurs, then it throws a IOException. If the connection is closed it is considered an error condition. If the stream has been configured to swap bytes using the setSwapBytes(boolean) method then this function will swap the order of the bytes within each 32-bit integer when they are sent. If listen or connect was called with the non-blocking flag set to false, then this method may block attempting to flush the stream buffer. All the data will be consumed and the total number of 32-bit integers sent is returned, which will be always be 1. Some of the data may remain in the stream buffer and not be sent until the next time flush() is called or there is no more room available in the stream buffer. If an error occurs then the a IOException is thrown and the stream should be closed. If listen or connect was called with the non-blocking flag set to true, then this method does not block. It returns the number of 32-bit integers sent successfully, which will be always be 1. If no 32-bit integers could be sent without blocking, then -ErrorCode.WouldBlock is returned. In this case, the poll(double, int) method may be used with the PollFlag.send flag to determine when space in the buffer becomes available. If an error occurs then a IOException is thrown and the stream should be closed. This method does not support two threads calling send or flush() at the same time. However, receive may be called by another thread at the same time as send.
      Parameters:
      value - The single value to write.
      Returns:
      The number of 32-bit integers written, which will always be 1. If no 32-bit integers could be written to the stream buffer and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • sendLong

      public int sendLong(long value) throws IOException
      Writes a single 64-bit integer (i.e., long) to the stream send buffer. This method writes data to the stream send buffer. It attempts to store one 64-bit integer in the internal stream buffer. If there is enough room available in the stream buffer then it stores the data in the buffer and returns immediately. The data is not written to the actual communication channel until the stream is flushed using flush() or there is no more room available in the stream buffer. If an error occurs, then it throws a IOException. If the connection is closed it is considered an error condition. If the stream has been configured to swap bytes using the setSwapBytes(boolean) method then this function will swap the order of the bytes within each 64-bit integer when they are sent. If listen or connect was called with the non-blocking flag set to false, then this method may block attempting to flush the stream buffer. All the data will be consumed and the total number of 64-bit integers sent is returned, which will be always be 1. Some of the data may remain in the stream buffer and not be sent until the next time flush() is called or there is no more room available in the stream buffer. If an error occurs then the a IOException is thrown and the stream should be closed. If listen or connect was called with the non-blocking flag set to true, then this method does not block. It returns the number of 32-bit integers sent successfully, which will be always be 1. If no 64-bit integers could be sent without blocking, then -ErrorCode.WouldBlock is returned. In this case, the poll(double, int) method may be used with the PollFlag.send flag to determine when space in the buffer becomes available. If an error occurs then a IOException is thrown and the stream should be closed. This method does not support two threads calling send or flush() at the same time. However, receive may be called by another thread at the same time as send.
      Parameters:
      value - The single value to write.
      Returns:
      The number of 64-bit integers written, which will always be 1. If no 64-bit integers could be written to the stream buffer and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • sendFloat

      public int sendFloat(float value) throws IOException
      Writes a single 32-bit, single-precision, floating-point (i.e., float) to the stream send buffer. This method writes data to the stream send buffer. It attempts to store one 32-bit, single-precision, floating-point number in the internal stream buffer. If there is enough room available in the stream buffer then it stores the data in the buffer and returns immediately. The data is not written to the actual communication channel until the stream is flushed using flush() or there is no more room available in the stream buffer. If an error occurs, then it throws a IOException. If the connection is closed it is considered an error condition. If the stream has been configured to swap bytes using the setSwapBytes(boolean) method then this function will swap the order of the bytes within each 32-bit floating-point number when they are sent. If listen or connect was called with the non-blocking flag set to false, then this method may block attempting to flush the stream buffer. All the data will be consumed and the total number of 32-bit floating-point numbers sent is returned, which will be always be 1. Some of the data may remain in the stream buffer and not be sent until the next time flush() is called or there is no more room available in the stream buffer. If an error occurs then the a IOException is thrown and the stream should be closed. If listen or connect was called with the non-blocking flag set to true, then this method does not block. It returns the number of 32-bit floating-point numbers sent successfully, which will be always be 1. If no 32-bit floating-point numbers could be sent without blocking, then -ErrorCode.WouldBlock is returned. In this case, the poll(double, int) method may be used with the PollFlag.send flag to determine when space in the buffer becomes available. If an error occurs then a IOException is thrown and the stream should be closed. This method does not support two threads calling send or flush() at the same time. However, receive may be called by another thread at the same time as send.
      Parameters:
      value - The single value to write.
      Returns:
      The number of 32-bit floating-point numbers written, which will always be 1. If no 32-bit floating-point numbers could be written to the stream buffer and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • sendDouble

      public int sendDouble(double value) throws IOException
      Writes a single 64-bit, double-precision, floating-point (i.e., double) to the stream send buffer. This method writes data to the stream send buffer. It attempts to store one 64-bit, double-precision, floating-point number in the internal stream buffer. If there is enough room available in the stream buffer then it stores the data in the buffer and returns immediately. The data is not written to the actual communication channel until the stream is flushed using flush() or there is no more room available in the stream buffer. If an error occurs, then it throws a IOException. If the connection is closed it is considered an error condition. If the stream has been configured to swap bytes using the setSwapBytes(boolean) method then this function will swap the order of the bytes within each 64-bit floating-point number when they are sent. If listen or connect was called with the non-blocking flag set to false, then this method may block attempting to flush the stream buffer. All the data will be consumed and the total number of 64-bit floating-point numbers sent is returned, which will be always be 1. Some of the data may remain in the stream buffer and not be sent until the next time flush() is called or there is no more room available in the stream buffer. If an error occurs then the a IOException is thrown and the stream should be closed. If listen or connect was called with the non-blocking flag set to true, then this method does not block. It returns the number of 64-bit floating-point numbers sent successfully, which will be always be 1. If no 64-bit floating-point numbers could be sent without blocking, then -ErrorCode.WouldBlock is returned. In this case, the poll(double, int) method may be used with the PollFlag.send flag to determine when space in the buffer becomes available. If an error occurs then a IOException is thrown and the stream should be closed. This method does not support two threads calling send or flush() at the same time. However, receive may be called by another thread at the same time as send.
      Parameters:
      value - The single value to write.
      Returns:
      The number of 64-bit floating-point numbers written, which will always be 1. If no 64-bit floating-point numbers could be written to the stream buffer and the method would block then -ErrorCode.WouldBlock is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • flush

      public boolean flush() throws IOException
      Flushes the stream send buffer to the underlying communication channel. This method flushes the stream buffer. It attempts to send the contents of the buffer over the communication channel, even if the buffer is not full. If an error occurs, then it throws a IOException. If the connection is closed it is considered an error condition. If listen or connect was called with the non-blocking flag set to false, then this method blocks until all the data in the buffer is sent. If listen or connect was called with the non-blocking flag set to true, then this method does not block. It attempts to send all the data remaining in the stream buffer. However, if this operation would block then it returns false, even if it has already sent some of the data. In this case, the poll(double, int) method may be used with the PollFlag.flush flag to determine when at least one more byte may be flushed. If an error occurs then a IOException is thrown and the stream should be closed. This method does not support two threads calling send or flush at the same time. However, receive may be called by another thread at the same time as flush.
      Returns:
      Returns true if all the data in the buffer is flushed successfully. If some of the data could not be sent over the underlying communication channel, then false is returned for non-blocking streams. If an error occurs then a IOException is thrown.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if an error has occurred in the underlying communication channel, such as the connection being lost unexpectedly.
    • shutdown

      public void shutdown() throws IOException
      Shuts down send and/or receive operations in preparation for closing the stream. It is typically called from another thread in order to interrupt a blocking send or receive operation prior to closing the stream. If an error occurs, then it throws IOException. If the connection is closed it is considered an error condition.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if the stream was closed prior to calling shutdown().
    • close

      public void close() throws IOException
      Closes the stream. This method closes the stream. All resources associated with the stream are freed. If an error occurs, then it throws IOException. If the connection is already closed it is considered an error condition.
      Throws:
      IOException - If an error occurs then an exception is thrown. This situation typically arises if the stream was already closed prior to calling close.
    • closeAll

      public void closeAll() throws IOException
      Closes all streams currently connected or listening. This method closes all streams that are currently connected or listening. All resources associated with those streams are freed. This method is typically used in exceptional conditions in order to ensure that all streams are closed. Note that only those streams that are associated with the current process are closed.
      Throws:
      IOException - If an error occurs then an exception is thrown.