|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--comm2j.Read2J
Read2J is a class used to communicate with another peer (J2ME or J2SE), transmitting
and receiving Messages throws an opened Socket connection.
Read2J supports compression (LZW), too. This means that you can send and
receive transparently data through a compression tunnel.
It's possible to have just a compressed way (eg: from server to client), so if
you have to send little quantity of data (that cannot be compressed), you can send
them raw.
The other peer will automatically recognise if the communication to him is
raw or compressed.
MessageI
Field Summary | |
static int |
COMPRESSED
Defines a compressed (LZW) communication between peers |
static int |
PACKLENGTH
Defines the number of bytes used to describe the lenght of the packet |
static int |
RAW
Defines a normal communication between peers |
Constructor Summary | |
Read2J()
Constructor. |
Method Summary | |
int |
getMode()
Returns the mode used by Read2J for the communication |
static int |
readLength(java.io.InputStream is)
Gets the length of the packet from given InputStream. The length is coded in 3 bytes, so it's possible to use just 7 bits per byte and armor the codes so that LZW can encode/decode them. |
Message |
readMessageFromStream(java.io.InputStream is)
Receive a message from the remote peer. It automatically recognises if the communication was compressed or not. |
void |
setMode(int mode)
Sets the mode used by Read2J for the communication |
static void |
writeLength(java.io.OutputStream os,
int len)
Sends the length of the packet throws given OutputStream. The length will be coded in 3 bytes, so it's possible to use just 7 bits per byte and armor the codes so that LZW can encode/decode them. |
int |
writeMessageToStream(Message msg,
java.io.OutputStream os)
Sends a message to the remote peer. If compression mode was set, the stream will be compressed. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int RAW
public static final int COMPRESSED
public static final int PACKLENGTH
Constructor Detail |
public Read2J()
Method Detail |
public int getMode()
public void setMode(int mode)
mode
- Communication mode to be usedpublic int writeMessageToStream(Message msg, java.io.OutputStream os) throws java.io.IOException
msg
- Message to be sentos
- OutputStreamjava.io.IOException
- if an error occouredpublic Message readMessageFromStream(java.io.InputStream is) throws java.io.IOException
is
- InputStreamjava.io.IOException
- if an error occouredpublic static void writeLength(java.io.OutputStream os, int len) throws java.io.IOException
os
- OutputStream to be usedlen
- Length to be sentjava.io.IOException
- if an error occoursLZW2J
public static int readLength(java.io.InputStream is) throws java.io.IOException
is
- InputStream to be usedjava.io.IOException
- if an error occoursLZW2J
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |