Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.caucho.vfs
Class SocketStream

    java.lang.Object
      |
      +--com.caucho.vfs.StreamImpl
            |
            +--com.caucho.vfs.SocketStream

public class SocketStream
extends StreamImpl

Specialized stream to handle sockets.

Unlike VfsStream, when the read() throws and IOException or a SocketException, SocketStream will throw a ClientDisconnectException.

Fields inherited from class com.caucho.vfs.StreamImpl
`nullPath, path`

Constructor Summary
`SocketStream(java.net.Socket s)`

Method Summary
`boolean` | `canRead()` Returns true since the socket stream can be read.
`boolean` | `canWrite()` Returns true if this is a writable stream.
`void` | `close()` Closes the underlying sockets and socket streams.
`void` | `flush()` Flushes the socket.
`int` | `getAvailable()` Returns the number of bytes available to be read from the input stream.
`byte[]` | `getNewline()` Returns the stream's natural newline character.
`void` | `init(java.net.Socket s)` Initialize the SocketStream with a new Socket.
`int` | `read(byte[] buf, int offset, int length)` Reads bytes from the socket.
`void` | `setNewline(byte[] newline)`
`void` | `write(byte[] buf, int offset, int length, boolean isEnd)` Writes bytes to the socket.

Methods inherited from class com.caucho.vfs.StreamImpl
`clearWrite, getAttribute, getAttributeNames, getFlushOnNewline, getPath, getReadPosition, hasSkip, removeAttribute, setAttribute, setPath, skip`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SocketStream

    public SocketStream(java.net.Socket s)

Method Detail

### init

    public void init(java.net.Socket s)

  Initialize the SocketStream with a new Socket.
  Parameters:
    `s` - the new socket.

### setNewline

    public void setNewline(byte[] newline)

### getNewline

    public byte[] getNewline()

  Description copied from class: `StreamImpl`
  Returns the stream's natural newline character.
  Overrides:
    `getNewline` in class `StreamImpl`

### canRead

    public boolean canRead()

  Returns true since the socket stream can be read.
  Overrides:
    `canRead` in class `StreamImpl`

### read

    public int read(byte[] buf,
                    int offset,
                    int length)
             throws java.io.IOException

  Reads bytes from the socket.
  Overrides:
    `read` in class `StreamImpl`
  Parameters:
    `buf` - byte buffer receiving the bytes
    `offset` - offset into the buffer
    `length` - number of bytes to read
  Returns:
    number of bytes read or -1
  Throws:
    `throws` - ClientDisconnectException if the connection is dropped

### getAvailable

    public int getAvailable()
                     throws java.io.IOException

  Returns the number of bytes available to be read from the input stream.
  Overrides:
    `getAvailable` in class `StreamImpl`

### canWrite

    public boolean canWrite()

  Description copied from class: `StreamImpl`
  Returns true if this is a writable stream.
  Overrides:
    `canWrite` in class `StreamImpl`

### write

    public void write(byte[] buf,
                      int offset,
                      int length,
                      boolean isEnd)
               throws java.io.IOException

  Writes bytes to the socket.
  Overrides:
    `write` in class `StreamImpl`
  Parameters:
    `buf` - byte buffer containing the bytes
    `offset` - offset into the buffer
    `length` - number of bytes to read
    `isEnd` - if the write is at a close.
  Throws:
    `throws` - ClientDisconnectException if the connection is dropped

### flush

    public void flush()
               throws java.io.IOException

  Flushes the socket.
  Overrides:
    `flush` in class `StreamImpl`

### close

    public void close()
               throws java.io.IOException

  Closes the underlying sockets and socket streams.
  Overrides:
    `close` in class `StreamImpl`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD