|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.funambol.platform.SocketAdapter
public class SocketAdapter
This class is a proxy to javax.microedition.io.SocketConnection to provide a common access to a socket resource on all mobile platforms. A portable code must use this class only to use sockets, and must take care of closing the SocketAdapter when not used anymore.
Example: void socketAccessExample(String host, int port) { SocketAdapter sa = new SocketAdapter(host, port); // opens the SocketConnection InputStream is = sa.openInputStream(); // opens the InputStream while( (char c = is.read()) != -1) { // read till the end of the file System.out.print(c); } is.close(); // closes the InputStream sa.close(); // closes the SocketConnection
Field Summary | |
---|---|
static byte |
DELAY
|
static byte |
KEEPALIVE
|
static byte |
LINGER
|
static byte |
RCVBUF
|
static int |
READ_WRITE
|
static byte |
SNDBUF
|
Constructor Summary | |
---|---|
SocketAdapter(java.lang.String host,
int port,
int mode,
boolean timeout)
Creates a FileAdapter instance, opening the underlying SocketConnection. |
Method Summary | |
---|---|
void |
close()
Close this Socket |
java.io.InputStream |
openInputStream()
Open and return an input stream for this Socket. |
java.io.OutputStream |
openOutputStream()
Open and return an output stream for this Socket. |
void |
setSocketOption(byte option,
int value)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final byte DELAY
public static final byte KEEPALIVE
public static final byte LINGER
public static final byte RCVBUF
public static final byte SNDBUF
public static final int READ_WRITE
Constructor Detail |
---|
public SocketAdapter(java.lang.String host, int port, int mode, boolean timeout) throws java.io.IOException
server
- is the remote server (without protocol specification)port
- is the remote port
java.io.IOException
- if the connection cannot be establishedMethod Detail |
---|
public java.io.InputStream openInputStream() throws java.io.IOException
java.io.IOException
public java.io.OutputStream openOutputStream() throws java.io.IOException
java.io.IOException
public void close() throws java.io.IOException
java.io.IOException
public void setSocketOption(byte option, int value) throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |