com.joctopus.client
Class Client

java.lang.Object
  extended by com.joctopus.client.Client

public class Client
extends java.lang.Object

This bean is used for opening client sockets to a remote machine.

Since:
1.0

Field Summary
static int BUFFER_SIZE
          buffer size in // MB..default=1MB
protected  boolean debug
          specifies debug mode, if true then output will be written to chatterconsole
static int DEFAULT_PORT
          default port for opening socket at remote machine,if not specified in constructor.
static int FILE_TRANSFER
           
static int TEXT_CHAT
          specifies type of messages passed,wheather text or binary messages,if size of message exceeds to kbs then file transfer should be best preferred.
 
Constructor Summary
Client()
          Default constructor
Client(java.net.InetAddress iDestination, int port, int mode, JOctopusConsole chatterConsole)
           
Client(java.net.InetAddress iDestination, int mode, JOctopusConsole chatterConsole)
           
 
Method Summary
 void connect()
          connects client to remote computer, can throw bind exception while sending muliple files, in such case it will wait for 300 ms and then again try to connect
 JOctopusConsole getChatterConsole()
           
 java.net.InetAddress getIDestination()
           
 java.io.InputStream getMessageAsStream()
           
 java.lang.String getMessageAsText()
           
 int getMode()
           
 int getPort()
           
 java.net.Socket getSocket()
           
 java.nio.channels.SocketChannel getSocketChannel()
           
 boolean isFail()
          Get the value of fail
 void run()
          sends message to client, can throw BindException when sending mutiple files in such case it will wait for 1000 ms and then again try to send file.
 void run0()
          same as run()
 void sendMessage()
          sends the message to remote machine.
 void setChatterConsole(JOctopusConsole chatterConsole)
           
 void setIDestination(java.net.InetAddress iDestination)
          sets the inetaddress of remote machine.
 void setMessageAsStream(java.io.InputStream messageAsStream)
          sets the stream that represents the file on the local system.
 void setMessageAsText(java.lang.String messageAsText)
          sets text message that will be sent at remote machine.
 void setMode(int mode)
          sets the mode of operation i.e text or file transfer
 void setPort(int port)
          sets port, to which this client will connect at remote host.
 void setSocketChannel(java.nio.channels.SocketChannel socketChannel)
           
 void shutDownClient()
          Closes all opened streams and channels
 void writeOut(java.lang.String message)
          writes output to JOctopusConsole window
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PORT

public static final int DEFAULT_PORT
default port for opening socket at remote machine,if not specified in constructor.

See Also:
Constant Field Values

TEXT_CHAT

public static final int TEXT_CHAT
specifies type of messages passed,wheather text or binary messages,if size of message exceeds to kbs then file transfer should be best preferred.

See Also:
Constant Field Values

FILE_TRANSFER

public static final int FILE_TRANSFER
See Also:
Constant Field Values

debug

protected boolean debug
specifies debug mode, if true then output will be written to chatterconsole


BUFFER_SIZE

public static int BUFFER_SIZE
buffer size in // MB..default=1MB

Constructor Detail

Client

public Client()
Default constructor


Client

public Client(java.net.InetAddress iDestination,
              int port,
              int mode,
              JOctopusConsole chatterConsole)
Parameters:
iDestination -
port -
mode -
chatterConsole -

Client

public Client(java.net.InetAddress iDestination,
              int mode,
              JOctopusConsole chatterConsole)
Parameters:
iDestination -
mode -
chatterConsole -
Method Detail

getChatterConsole

public JOctopusConsole getChatterConsole()
Returns:
ChatterConsole

setChatterConsole

public void setChatterConsole(JOctopusConsole chatterConsole)
Parameters:
chatterConsole - JOctopusConsole object for debugging purposes

isFail

public boolean isFail()
Get the value of fail

Returns:
the value of fail

setSocketChannel

public void setSocketChannel(java.nio.channels.SocketChannel socketChannel)
Parameters:
socketChannel - SocketChannel to set.

getSocketChannel

public java.nio.channels.SocketChannel getSocketChannel()
Returns:
socket channel, if client is used for file transfer operation

getMode

public int getMode()
Returns:
mode of operation, i.e text or filetransfer

setMode

public void setMode(int mode)
sets the mode of operation i.e text or file transfer

Parameters:
mode -

getPort

public int getPort()
Returns:
port of remote machine at which this client has obtained connection.

setPort

public void setPort(int port)
sets port, to which this client will connect at remote host.

Parameters:
port -

getMessageAsText

public java.lang.String getMessageAsText()
Returns:
text message that will be used for sending message at remote machine.

setMessageAsText

public void setMessageAsText(java.lang.String messageAsText)
sets text message that will be sent at remote machine.

Parameters:
messageAsText -

getSocket

public java.net.Socket getSocket()
Returns:
socket that has established connection at remote machine

getIDestination

public java.net.InetAddress getIDestination()
Returns:
inetaddress of remote machine

setIDestination

public void setIDestination(java.net.InetAddress iDestination)
sets the inetaddress of remote machine.

Parameters:
iDestination -

getMessageAsStream

public java.io.InputStream getMessageAsStream()
Returns:
message that represents the stream(file)

setMessageAsStream

public void setMessageAsStream(java.io.InputStream messageAsStream)
sets the stream that represents the file on the local system.

Parameters:
messageAsStream -

sendMessage

public void sendMessage()
sends the message to remote machine.


shutDownClient

public void shutDownClient()
Closes all opened streams and channels


writeOut

public void writeOut(java.lang.String message)
writes output to JOctopusConsole window

Parameters:
message -

connect

public void connect()
connects client to remote computer, can throw bind exception while sending muliple files, in such case it will wait for 300 ms and then again try to connect


run

public void run()
sends message to client, can throw BindException when sending mutiple files in such case it will wait for 1000 ms and then again try to send file.


run0

public void run0()
same as run()