netP5
Class AbstractTcpClient

java.lang.Object
  extended by netP5.AbstractTcpClient
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
TcpClient

public abstract class AbstractTcpClient
extends Object
implements Runnable


Field Summary
static int MODE_NEWLINE
          terminator is newline.
static int MODE_READLINE
          terminator is readline.
static int MODE_STREAM
          no terminator required, packets are sent via a tcp stream.
static int MODE_TERMINATED
          terminator is terminated, by default this is character '\0' and can be set with setTerminator
 
Constructor Summary
AbstractTcpClient(AbstractTcpServer theTcpServer, Socket theSocket, TcpPacketListener theTcpPacketListener, int theServerPort, int theMode)
           
AbstractTcpClient(String theHost, int thePort)
           
AbstractTcpClient(String theHost, int thePort, int theMode)
           
AbstractTcpClient(TcpPacketListener theTcpPacketListener, String theHost, int thePort)
           
AbstractTcpClient(TcpPacketListener theTcpPacketListener, String theHost, int thePort, int theMode)
           
 
Method Summary
 void dispose()
          stop and dispose a tcp client.
 boolean equals(NetAddress theNetAddress)
           
 boolean equals(TcpClient theClient)
           
 String getString()
           
 StringBuffer getStringBuffer()
           
abstract  void handleInput()
           
abstract  void handleStatus(int theIndex)
           
 TcpPacketListener listener()
           
 int mode()
          get the mode of the terminator.
 NetAddress netaddress()
          Deprecated.  
 NetAddress netAddress()
           
 void reconnect()
          when a TCP connection is lost, reconnect to the server with reconnect().
 void run()
           
 void send(byte[] theBytes)
           
 void send(byte[][] theBytes)
           
 void send(String theString)
           
 int serverport()
          get the server port.
 void setTerminator(char theTerminator)
          to parse an incomming tcp message, a terminator character is required to determine the end of the message so that it can be parsed and forwarded.
 Socket socket()
          get the instance of the socket.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_READLINE

public static final int MODE_READLINE
terminator is readline.

See Also:
Constant Field Values

MODE_TERMINATED

public static final int MODE_TERMINATED
terminator is terminated, by default this is character '\0' and can be set with setTerminator

See Also:
Constant Field Values

MODE_NEWLINE

public static final int MODE_NEWLINE
terminator is newline.

See Also:
Constant Field Values

MODE_STREAM

public static final int MODE_STREAM
no terminator required, packets are sent via a tcp stream.

See Also:
Constant Field Values
Constructor Detail

AbstractTcpClient

public AbstractTcpClient(TcpPacketListener theTcpPacketListener,
                         String theHost,
                         int thePort)
Parameters:
theTcpPacketListener - TcpPacketListener
theHost - String
thePort - int

AbstractTcpClient

public AbstractTcpClient(String theHost,
                         int thePort)
Parameters:
theHost - String
thePort - int

AbstractTcpClient

public AbstractTcpClient(TcpPacketListener theTcpPacketListener,
                         String theHost,
                         int thePort,
                         int theMode)
Parameters:
theTcpPacketListener - TcpPacketListener
theHost - String
thePort - int
theMode - int

AbstractTcpClient

public AbstractTcpClient(String theHost,
                         int thePort,
                         int theMode)
Parameters:
theHost - String
thePort - int
theMode - int

AbstractTcpClient

public AbstractTcpClient(AbstractTcpServer theTcpServer,
                         Socket theSocket,
                         TcpPacketListener theTcpPacketListener,
                         int theServerPort,
                         int theMode)
Parameters:
theTcpServer - AbstractTcpServer
theSocket - Socket
theTcpPacketListener - TcpPacketListener
theServerPort - int
theMode - int
Method Detail

reconnect

public void reconnect()
when a TCP connection is lost, reconnect to the server with reconnect().


setTerminator

public void setTerminator(char theTerminator)
to parse an incomming tcp message, a terminator character is required to determine the end of the message so that it can be parsed and forwarded.

Parameters:
theTerminator -

dispose

public void dispose()
stop and dispose a tcp client.


run

public void run()
Specified by:
run in interface Runnable

handleInput

public abstract void handleInput()

handleStatus

public abstract void handleStatus(int theIndex)
Parameters:
theIndex -

listener

public TcpPacketListener listener()
Returns:

serverport

public int serverport()
get the server port.

Returns:

socket

public Socket socket()
get the instance of the socket. more info at java.net.Socket

Returns:

mode

public int mode()
get the mode of the terminator.

Returns:

getString

public String getString()

getStringBuffer

public StringBuffer getStringBuffer()

send

public void send(byte[] theBytes)

send

public void send(byte[][] theBytes)

send

public void send(String theString)

netAddress

public NetAddress netAddress()

netaddress

public NetAddress netaddress()
Deprecated. 

Returns:
NetAddress

equals

public boolean equals(NetAddress theNetAddress)
Parameters:
theNetAddress - NetAddress
Returns:
boolean

equals

public boolean equals(TcpClient theClient)


processing library oscP5 by Andreas Schlegel. (c) 2004-2012