Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.squawk.platform
Interface GCFSockets

All Known Implementing Classes:
  GCFSocketsImpl, GCFSocketsImpl

    public interface GCFSockets

This defines the interface between the GCF sockets protocol and the platform's SocketAdapter. This interface is not designed for other uses.

Method Summary
`int` | `accept(int fd)` Accept client connections on server socket fd.
`int` | `available(int handle)` Gets the number of bytes that can be read without blocking.
`void` | `close(int handle)` Closes the socket connection.
`int` | `getSockOpt(int socket, int option_name)` get a socket option
`int` | `open(String hostname, int port, int mode)` Opens a TCP connection to a server.
`int` | `openServer(int port, int backlog)` Opens a server TCP connection to clients.
`int` | `readBuf(int handle, byte[] b, int off, int len)` Reads from the open socket connection.
`int` | `readByte(int handle)` Read a byte from the open socket connection.
`int` | `readByte(int fd, byte[] b)` Read a byte from the open socket connection.
`void` | `setSockOpt(int socket, int option_name, int option_value)` set a socket option
`int` | `writeBuf(int handle, byte[] b, int off, int len)` Writes to the open socket connection.
`int` | `writeByte(int handle, int b)` Writes to the open socket connection.

Method Detail

### open

    int open(String hostname,
             int port,
             int mode)
             throws IOException

  Opens a TCP connection to a server.

  Parameters:
    `hostname` - host name
    `port` - TCP port at host
    `mode` - connection mode (ignored, should be read/write?
  Returns:
    a native handle to the network connection.
  Throws:
    `IOException`

### openServer

    int openServer(int port,
                   int backlog)
                   throws IOException

  Opens a server TCP connection to clients. Creates, binds, and listens

  Parameters:
    `port` - local TCP port to listen on
    `backlog` - listen backlog.
  Returns:
    a native handle to the network connection.
  Throws:
    `IOException`

### accept

    int accept(int fd)
               throws IOException

  Accept client connections on server socket fd. Blocks until a client connects.

  Parameters:
    `fd` - open server socket. See `openServer(int, int)`.
  Returns:
    a native handle to the network connection.
  Throws:
    `IOException`

### readBuf

    int readBuf(int handle,
                byte[] b,
                int off,
                int len)
                throws IOException

  Reads from the open socket connection.

  Parameters:
    `handle` - the socket descriptor
    `b` - the buffer into which the data is read.
    `off` - the start offset in array `b` at which the data is written.
    `len` - the maximum number of bytes to read.
  Returns:
    the total number of bytes read into the buffer, or `-1` if there is no mo data because the end of the stream has been reached.
  Throws:
    `IOException`

### readByte

    int readByte(int handle)
                 throws IOException

  Read a byte from the open socket connection. This function will return an unsigned byte (0-255) if data was read, or -1 if EOF was reached.

  Parameters:
    `fd` - the socket descriptor
  Returns:
    the byte read or -1
  Throws:
    `IOException`

### readByte

    int readByte(int fd,
                 byte[] b)
                 throws IOException

  Read a byte from the open socket connection. This function will return an unsigned byte (0-255) if data was read, or -1 if EOF was reached. This version is passed a temporary buffer instead of allocating one.

  Parameters:
    `fd` - the socket descriptor
    `b` -
  Returns:
    the byte read or -1
  Throws:
    `IOException`

### writeBuf

    int writeBuf(int handle,
                 byte[] b,
                 int off,
                 int len)
                 throws IOException

  Writes to the open socket connection.

  Parameters:
    `handle` - the socket descriptor
    `b` - the buffer of the data to write
    `off` - the start offset in array `b` at which the data is written.
    `len` - the number of bytes to write.
  Returns:
    the total number of bytes written
  Throws:
    `IOException`

### writeByte

    int writeByte(int handle,
                  int b)
                  throws IOException

  Writes to the open socket connection.

  Parameters:
    `handle` - the socket descriptor
    `b` - the byte to write
  Returns:
    the total number of bytes written
  Throws:
    `IOException`

### available

    int available(int handle)
                  throws IOException

  Gets the number of bytes that can be read without blocking.

  Parameters:
    `handle` - the socket descriptor
  Returns:
    number of bytes that can be read without blocking
  Throws:
    `IOException`

### close

    void close(int handle)
               throws IOException

  Closes the socket connection.

  Parameters:
    `handle` - the socket descriptor
  Throws:
    `IOException`

### setSockOpt

    void setSockOpt(int socket,
                    int option_name,
                    int option_value)
                    throws IOException

  set a socket option

  Parameters:
    `socket` - socket descriptor
    `option_name` -
    `option_value` - new value
  Throws:
    `IOException` - on error

### getSockOpt

    int getSockOpt(int socket,
                   int option_name)
                   throws IOException

  get a socket option

  Parameters:
    `socket` - socket descriptor
    `option_name` -
  Returns:
    option value
  Throws:
    `IOException` - on error

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

"
For updated information see the Java FRC site
"