|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.monica.javacom.transport.MJCTCPTransport
This class provides TCP based connection over IP as a MJCTransport. MJCTCPTransport
provides both server and client services. This class implements buffering in both
directions.
Configureable values:
Constructor Summary | |
MJCTCPTransport()
Normal constructor. |
|
MJCTCPTransport(java.net.Socket client)
Create a new thread for a new server. |
Method Summary | |
java.lang.String |
checkSum(java.lang.String s)
Generates a checksum for a String. |
void |
closeConnections()
Close all active connections |
void |
flush()
Flushes the contents of the write buffer to bottom layers. |
int |
getAvailable()
Returns the number of bytes that are available for read out from this MJCReadable. |
MJCConfiguration |
getConfiguration()
Returns the MJCConfiguration with which this object is customized. |
java.lang.String |
getInput()
Get back the data arrived from the socket and read out by listenForRead. |
java.lang.String |
getLastWriteableError()
Returns the error message of the last occured error. |
java.lang.String |
getReadableName()
Returns the MJC name of the MJCReadable. |
java.lang.String |
getReadableVersion()
Returns the MJC version of the MJCReadable. |
MJCReader |
getReader()
Returns the MJCReader to which readEvents will be sent. |
MJCServerManager |
getServerManager()
Returns the MJCServerManager which will be notified if a client connects. |
java.lang.String |
getTransportName()
Returns the MJC name of the MJCTransport. |
java.lang.String |
getTransportVersion()
Returns the MJC version of the MJCTransport. |
java.lang.String |
getWriteableName()
Returns the MJC name of the MJCWriteable. |
java.lang.String |
getWriteableVersion()
Returns the MJC version of the MJCWriteable. |
void |
initAsClient(java.lang.String host,
int port)
Initializes the MJCTransport as the client side. |
void |
initAsServer(int port)
Initializes the MJCTransport as the server side. |
boolean |
isReadableConnected()
Returns wether the MJCReadable is still connected to its source. |
boolean |
isWriteableConnected()
Returns wether the MJCWriteable is connected to its target. |
void |
run()
Runnable run method. |
void |
setConfiguration(MJCConfiguration configuration)
Sets the MJCConfiguration for this object. |
void |
setReader(MJCReader reader)
Sets the MJCReader to which the readEvents have to be sent. |
void |
setServerManager(MJCServerManager serverManager)
Sets the MJCServerManager which will be notified if a client connects. |
boolean |
write(char c)
Writes one single char. |
boolean |
write(char[] c)
Writes a char array. |
boolean |
write(java.lang.String s)
Writes a String. |
void |
writeOut(java.lang.String s)
Writes out a String directly to the TCP socket without buffering. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public MJCTCPTransport()
public MJCTCPTransport(java.net.Socket client) throws java.io.IOException
Socket
- client: the client of this server threadMethod Detail |
public void initAsServer(int port) throws java.io.IOException
initAsServer
in interface MJCTransport
int
- port: the port where the clients can connectIOException:
- if the server could not be startedpublic void initAsClient(java.lang.String host, int port) throws java.io.IOException
initAsClient
in interface MJCTransport
String
- host: the destination hostint
- port: the destination portIOException:
- if the client cannot connect to
the specified host and portpublic void run()
run
in interface java.lang.Runnable
public void flush()
flush
in interface MJCWriteable
public void writeOut(java.lang.String s)
String
- s: the String to be written outpublic java.lang.String getInput()
getInput
in interface MJCReadable
public void closeConnections()
closeConnections
in interface MJCTransport
public java.lang.String getTransportName()
getTransportName
in interface MJCTransport
public java.lang.String getTransportVersion()
getTransportVersion
in interface MJCTransport
public void setReader(MJCReader reader)
setReader
in interface MJCReadable
MJCReader
- reader: the MJCReader to which the readEvents
have to be sentpublic MJCReader getReader()
getReader
in interface MJCReadable
public void setServerManager(MJCServerManager serverManager)
setServerManager
in interface MJCTransport
MJCServerManager
- serverManager: the MJCServerManager
that has to be notified if a client connectspublic MJCServerManager getServerManager()
getServerManager
in interface MJCTransport
public void setConfiguration(MJCConfiguration configuration)
setConfiguration
in interface MJCConfigureable
MJCConfiguration
- configuration: the MJCConfiguration
object for the customizationpublic MJCConfiguration getConfiguration()
getConfiguration
in interface MJCConfigureable
public java.lang.String getWriteableName()
getWriteableName
in interface MJCWriteable
public java.lang.String getWriteableVersion()
getWriteableVersion
in interface MJCWriteable
public boolean write(char c)
write
in interface MJCWriteable
char
- c: the char to be writtenpublic boolean write(java.lang.String s)
write
in interface MJCWriteable
String
- s: the String to be writtenpublic boolean write(char[] c)
write
in interface MJCWriteable
char[]
- c: the char array to be writtenpublic java.lang.String getLastWriteableError()
getLastWriteableError
in interface MJCWriteable
public boolean isWriteableConnected()
isWriteableConnected
in interface MJCWriteable
public java.lang.String getReadableName()
getReadableName
in interface MJCReadable
public java.lang.String getReadableVersion()
getReadableVersion
in interface MJCReadable
public int getAvailable()
getAvailable
in interface MJCReadable
public boolean isReadableConnected()
isReadableConnected
in interface MJCReadable
public java.lang.String checkSum(java.lang.String s)
checkSum
in interface MJCTransport
String:
- the String for which a checksum is needed
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |