UC Berkeley Group for User Interface Research
Updated November 17, 2000

edu.berkeley.guir.lib.net
Class SimpleClient

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--edu.berkeley.guir.lib.net.SimpleClient
All Implemented Interfaces:
NetConstants, Runnable

public class SimpleClient
extends Thread
implements NetConstants

Sends data to a specified address and port, and echoes anything received.

This software is distributed under the Berkeley Software License.

 Revisions:  - GUIRLib-v1.0-1.0.0, Jun 16 1998, JH
               Created class
             - GUIRLib-v1.2-1.0.0, Jun 22 2000, JH
               Touched for GUIRLib release
             - GUIRLib-v1.3-1.0.0, Aug 11 2000, JH
               Touched for GUIRLib release
             - GUIRLib-v1.4-1.0.0, Aug 31 2000, JH
               Touched for GUIRLib release
 

Since:
JDK 1.1.6
Version:
GUIRLib-v1.4-1.0.0, Aug 31 2000
Author:
Jason Hong ( jasonh@cs.berkeley.edu )

Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface edu.berkeley.guir.lib.net.NetConstants
ANYPORT, DEFAULT_TIMEOUT, NO_TIMEOUT
 
Constructor Summary
SimpleClient(InetAddress dstAddr, int dstPort)
          Use the current address using any port to connect to the specified destination and port.
SimpleClient(InetAddress dstAddr, int dstPort, int iTimeout)
          Use the current address using any port to connect to the specified destination and port with the specified timeout.
SimpleClient(int srcPort, InetAddress dstAddr, int dstPort)
          Use the current address and the specified port to connect to the specified destination and port.
SimpleClient(int srcPort, InetAddress dstAddr, int dstPort, int iTimeout)
          Use the current address and the specified port to connect to the specified destination and port.
 
Method Summary
 void close()
          Close the client.
 void finalize()
           
static void main(String[] argv)
           
 void run()
          Connect the socket to the destination.
 void setDestinationAddress(InetAddress dstAddr)
          Set the address to connect to.
 void setDestinationPort(int dstPort)
          Set the port to connect to.
 void setFilter(String strFilter)
          Set the characters to filter out.
 void setInputStream(InputStream istream)
          Input from this stream will be sent to the socket.
 void setOutputStream(OutputStream ostream)
          Anything read from the socket goes to this OutputStream.
 void setSourcePort(int srcPort)
          Set the port to connect from.
 void setTimeout(int timeout)
          Set the timeout value.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleClient

public SimpleClient(InetAddress dstAddr,
                    int dstPort)
Use the current address using any port to connect to the specified destination and port.
Parameters:
dstAddr - is the address to connect to.
dstPort - is the port to connect to.

SimpleClient

public SimpleClient(InetAddress dstAddr,
                    int dstPort,
                    int iTimeout)
Use the current address using any port to connect to the specified destination and port with the specified timeout.
Parameters:
dstAddr - is the address to connect to.
dstPort - is the port to connect to.
iTimeout - is the length of time to wait for a connection.

SimpleClient

public SimpleClient(int srcPort,
                    InetAddress dstAddr,
                    int dstPort)
Use the current address and the specified port to connect to the specified destination and port.
Parameters:
srcPort - is the port to connect from.
dstAddr - is the address to connect to.
dstPort - is the port to connect to.

SimpleClient

public SimpleClient(int srcPort,
                    InetAddress dstAddr,
                    int dstPort,
                    int iTimeout)
Use the current address and the specified port to connect to the specified destination and port.
Parameters:
srcPort - is the port to connect from.
dstAddr - is the address to connect to.
dstPort - is the port to connect to.
iTimeout - is the length of time to wait for a connection.
Method Detail

run

public void run()
Connect the socket to the destination.
Overrides:
run in class Thread

close

public void close()
Close the client.

finalize

public void finalize()
Overrides:
finalize in class Object

setFilter

public void setFilter(String strFilter)
Set the characters to filter out.
Parameters:
strFilter - is the String of characters to filter out before sending the message to the server.

setSourcePort

public void setSourcePort(int srcPort)
Set the port to connect from.
Parameters:
srcPort - is the port to connect from.

setDestinationPort

public void setDestinationPort(int dstPort)
Set the port to connect to.
Parameters:
srcPort - is the port to connect to.

setDestinationAddress

public void setDestinationAddress(InetAddress dstAddr)
Set the address to connect to.
Parameters:
dstAddr - is the Internet address to connect to.

setTimeout

public void setTimeout(int timeout)
Set the timeout value.
Parameters:
timeout - is the timeout to set to. Negative values not allowed.

setInputStream

public void setInputStream(InputStream istream)
Input from this stream will be sent to the socket.
Parameters:
istream - will be redirected as input to the socket.

setOutputStream

public void setOutputStream(OutputStream ostream)
Anything read from the socket goes to this OutputStream.
Parameters:
ostream - is where socket output will be redirected.

main

public static void main(String[] argv)
                 throws Exception

Copyright Information