|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ccg.util.Convert
com.ccg.util.TagLookup
com.ccg.util.CommandLineUtility
com.ccg.net.tcp.Cat
public class Cat
Program to "cat" data from a TCP connection (and test the URLConnection class.
This is a rather useful utility which excercises the URLConnection class. It allows one to specify
Currently this utility doesn't use the standard input supported
by the CommandLineUtility class, but does support the
command line options related to the standard output. The additional
command line options recognized include:
URLURLConnection class. This is a very flexible way to
open the connection. It allows the application to either make the
connection to TCP server, or act as a TCP server and wait for an
incoming connection. In addition, one can specify various socket options to affect the low level settings of
the TCP connection.
Here is a simple example to see what the "telnet" service spits
out on an initial connection. We will use Cat to make the
connection to the "telnet" server and dump the initial bytes
received in their "hex" form:
java com.ccg.net.tcp.Cat -hex -url tcp://rice:23
Going in the other direction, you can listen on a port (say
10080) and point "lynx" or "netscape" at it requesting a
document. First, we set up the "server" using Cat,
notice how we omit the "host" to put the "tcp:" URL into "listen"
mode:
java com.ccg.net.tcp.Cat -url tcp://:10080/
Now, let's point "lynx" at it with the following command line to see what is initially sent by the browser:
lynx http://localhost:10080/index.html
URLConnection| Constructor Summary | |
|---|---|
Cat(String[] args)
Standard CommandLineUtility constructor. |
|
| Method Summary | |
|---|---|
static void |
main(String[] args)
Main entry point into the application. |
void |
run()
Main loop of the program. |
| Methods inherited from class com.ccg.util.CommandLineUtility |
|---|
getFiles, getInputStream, getLineNumberReader, getOutputStream, getPrintWriter, getStrings, setInputStream, setOutputStream |
| Methods inherited from class com.ccg.util.TagLookup |
|---|
get, getBoolean, getChoice, getColor, getDate, getDate, getFont, getIndexedList, getInputStream, getLocale, getLookup, getNumber, getNumber, getOutputStream, getString, getString, getStrings, getTag, getTimeSpan, getTimeSpan, setLookup, setTag |
| Methods inherited from class com.ccg.util.Convert |
|---|
choiceValue, getDateFormat, getNumberFormat, setDateFormat, setNumberFormat, toBoolean, toColor, toDate, toFont, toInputStream, toLocale, toNumber, toOutputStream, toString, toTimeSpan |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Cat(String[] args)
CommandLineUtility constructor.
This is the standard way to initialize CommandLineUtility based applications. It sets the properties
for the application and makes the application ready to be run. All of the real work is done in the run()
method.
run()| Method Detail |
|---|
public void run()
class.
SocketOptions for
TCP sockets.
run in interface Runnablerun in class CommandLineUtilityCatpublic static void main(String[] args)
creates the object and
then runs it.
args - Array of command line arguments.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||