2010 FRC Java API


com.sun.squawk.platform.windows
Class GCFSocketsImpl

java.lang.Object
  extended by com.sun.squawk.platform.windows.GCFSocketsImpl
All Implemented Interfaces:
GCFSockets

public class GCFSocketsImpl
extends Object
implements GCFSockets

POSIX implementation of GCFSockets that calls the BSD socket API.


Constructor Summary
GCFSocketsImpl()
           
 
Method Summary
 int accept(int fd)
          Accept client connections on server socket fd.
 int available(int fd)
          Gets the number of bytes that can be read without blocking.
 void close(int fd)
          Closes the socket connection.
 int getSockOpt(int socket, int option_name)
          get a socket option
static String inet_ntop(int in)
          Takes an IPv4 Internet address and returns string representing the address in `.' notation
 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 fd, byte[] b, int offset, int length)
          Reads from the open socket connection.
 int readByte(int fd)
          Reada a byte from the open socket connection
 void setSockOpt(int socket, int option_name, int option_value)
          set a socket option
 int writeBuf(int fd, byte[] buffer, int off, int len)
          Writes to the open socket connection.
 int writeByte(int fd, int b)
          Writes to the open socket connection.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GCFSocketsImpl

public GCFSocketsImpl()
Method Detail

accept

public int accept(int fd)
           throws IOException
Accept client connections on server socket fd. Blocks until a client connects.

Specified by:
accept in interface GCFSockets
Parameters:
fd - open server socket. See openServer(int, int).
Returns:
a native handle to the network connection.
Throws:
IOException

available

public int available(int fd)
              throws IOException
Description copied from interface: GCFSockets
Gets the number of bytes that can be read without blocking.

Specified by:
available in interface GCFSockets
Parameters:
fd - the socket descriptor
Returns:
number of bytes that can be read without blocking
Throws:
IOException

close

public void close(int fd)
           throws IOException
Description copied from interface: GCFSockets
Closes the socket connection.

Specified by:
close in interface GCFSockets
Parameters:
fd - the socket descriptor
Throws:
IOException

getSockOpt

public int getSockOpt(int socket,
                      int option_name)
               throws IOException
get a socket option

Specified by:
getSockOpt in interface GCFSockets
Parameters:
socket - socket descriptor
option_name -
Returns:
option value
Throws:
IOException - on error

inet_ntop

public static String inet_ntop(int in)
Takes an IPv4 Internet address and returns string representing the address in `.' notation

Parameters:
in - the opaque bytes of an IPv4 "struct in_addr"
Returns:
String

open

public int open(String hostname,
                int port,
                int mode)
         throws IOException
Description copied from interface: GCFSockets
Opens a TCP connection to a server.

Specified by:
open in interface GCFSockets
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

public int openServer(int port,
                      int backlog)
               throws IOException
Opens a server TCP connection to clients. Creates, binds, and listens

Specified by:
openServer in interface GCFSockets
Parameters:
port - local TCP port to listen on
backlog - listen backlog.
Returns:
a native handle to the network connection.
Throws:
IOException

readBuf

public int readBuf(int fd,
                   byte[] b,
                   int offset,
                   int length)
            throws IOException
Description copied from interface: GCFSockets
Reads from the open socket connection.

Specified by:
readBuf in interface GCFSockets
Parameters:
fd - the socket descriptor
b - the buffer into which the data is read.
offset - the start offset in array b at which the data is written.
length - 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

public int readByte(int fd)
             throws IOException
Description copied from interface: GCFSockets
Reada a byte from the open socket connection. * This function will return an unsigned byte, or -1. -1 means that EOF was reached.

Specified by:
readByte in interface GCFSockets
Parameters:
fd - the socket descriptor
Returns:
the byte read
Throws:
IOException

setSockOpt

public void setSockOpt(int socket,
                       int option_name,
                       int option_value)
                throws IOException
set a socket option

Specified by:
setSockOpt in interface GCFSockets
Parameters:
socket - socket descriptor
option_name -
option_value - new value
Throws:
IOException - on error

writeBuf

public int writeBuf(int fd,
                    byte[] buffer,
                    int off,
                    int len)
             throws IOException
Description copied from interface: GCFSockets
Writes to the open socket connection.

Specified by:
writeBuf in interface GCFSockets
Parameters:
fd - the socket descriptor
buffer - 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

public int writeByte(int fd,
                     int b)
              throws IOException
Description copied from interface: GCFSockets
Writes to the open socket connection.

Specified by:
writeByte in interface GCFSockets
Parameters:
fd - the socket descriptor
b - the byte to write
Returns:
the total number of bytes written
Throws:
IOException

2010 FRC Java API


Copyright © 2006-2009 Sun Microsystems, Inc. All Rights Reserved.