roomba.roombanetwork.util
Class SocketClient

java.lang.Object
  extended by roomba.roombanetwork.util.SocketClient
All Implemented Interfaces:
java.lang.Runnable

public class SocketClient
extends java.lang.Object
implements java.lang.Runnable

This class connects to a socket server to send messages to the server

Author:
Drew Housten

Constructor Summary
SocketClient(java.lang.String host, int port)
          The constructor for the client.
SocketClient(java.lang.String host, int port, boolean verbose)
          The constructor for the client.
 
Method Summary
 void closeSocket()
          Closes the socket connection
 int getQueueSize()
          Returns the current size of the waiting queue
 void limitQueueSize(int maxQueueSize)
          Used to limit the maximum size of the waiting queue.
static void main(java.lang.String[] args)
          Test main to send a message to a server
 void run()
          Run method that controls the functionality of the client connection
 void sendString(java.lang.String s)
          Adds a string to the queue to send
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocketClient

public SocketClient(java.lang.String host,
                    int port)
The constructor for the client.

Parameters:
host - The host that the client is connecting to
port - The port that the client is connecting to

SocketClient

public SocketClient(java.lang.String host,
                    int port,
                    boolean verbose)
The constructor for the client.

Parameters:
host - The host that the client is connecting to
port - The port that the client is connecting to
verbose - True iff the client output should be verbose
Method Detail

run

public void run()
Run method that controls the functionality of the client connection

Specified by:
run in interface java.lang.Runnable

closeSocket

public void closeSocket()
Closes the socket connection


getQueueSize

public int getQueueSize()
Returns the current size of the waiting queue

Returns:
The current size of the waiting queue

limitQueueSize

public void limitQueueSize(int maxQueueSize)
Used to limit the maximum size of the waiting queue. Any additional messages will be discarded. By default, this is not used.

Parameters:
maxQueueSize - The max queue size to set

sendString

public void sendString(java.lang.String s)
Adds a string to the queue to send

Parameters:
s - The string to send

main

public static final void main(java.lang.String[] args)
Test main to send a message to a server