DCT Lightfoot v3 API specification

com.dctl.j2me.net
Class TCP

java.lang.Object
  |
  +--com.dctl.j2me.net.TCP

public class TCP
extends Object

This wraps up all the TCP socket methods


Constructor Summary
TCP()
           
 
Method Summary
static int available(int handle)
          Return the number of bytes available in the buffer
static void close(int handle)
          Close a socket
static void connect(int handle, int address, int port)
          Connect the socket to a server
static int createSocket()
          Create a new socket
static void flush(int handle)
          Flush the buffer
static int read(int handle)
          Return one byte of data from the stream
static int read(int handle, byte[] buf, int off, int len)
          Read into a buffer from the stream
static int skip(int handle, int n)
          Skip a number of bytes
static void write(int handle, byte[] buf, int off, int len)
          Write a buffer to the stream
static void write(int handle, int b)
          Write one byte to the socket
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TCP

public TCP()
Method Detail

createSocket

public static int createSocket()
                        throws IOException
Create a new socket

Returns:
the handle to use
Throws:
IOException - if there is an error

connect

public static void connect(int handle,
                           int address,
                           int port)
                    throws IOException
Connect the socket to a server

Parameters:
handle - The handle
address - The address of the server
port - The port on the server to connect to
Throws:
IOException - if there is an error

close

public static void close(int handle)
                  throws IOException
Close a socket

Parameters:
handle - The handle
Throws:
IOException - if there is an error

available

public static int available(int handle)
                     throws IOException
Return the number of bytes available in the buffer

Parameters:
handle - The handle
Throws:
IOException - if there is an error

read

public static int read(int handle)
                throws IOException
Return one byte of data from the stream

Parameters:
handle - The handle
Returns:
the byte or -1 if end of file
Throws:
IOException - if there is an error

read

public static int read(int handle,
                       byte[] buf,
                       int off,
                       int len)
                throws IOException
Read into a buffer from the stream

Parameters:
handle - The handle
buf - The buffer
off - The offset into the buffer
len - The maximum length to read
Returns:
the number of bytes read or -1 if EOF
Throws:
IOException - if there is an error

skip

public static int skip(int handle,
                       int n)
                throws IOException
Skip a number of bytes

Parameters:
handle - The handle
n - The number of bytes to skip
Returns:
the number of bytes skipped
Throws:
IOException - if there is an error

write

public static void write(int handle,
                         int b)
                  throws IOException
Write one byte to the socket

Parameters:
handle - The handle
b - The byte to write
Throws:
IOException - if there is an error

write

public static void write(int handle,
                         byte[] buf,
                         int off,
                         int len)
                  throws IOException
Write a buffer to the stream

Parameters:
handle - The handle
buf - The buffer
off - The offset into the buffer
len - The maximum length to write
Throws:
IOException - if there is an error

flush

public static void flush(int handle)
                  throws IOException
Flush the buffer

Parameters:
handle - The handle
Throws:
IOException - if there is an error

DCT Lightfoot v3 API specification

DCT Lightfoot v3 API specification