//
Written by W.Buchanan, Aug 2003
// client.java
// Run the program with java
client 127.0.0.1 1000 for
port 1000 on 127.0.0.1
import
java.net.*;
import java.io.*;
import java.util.*;
import java.lang.Integer;
public
class client extends Thread
{
public static void main( String arg[])
throws IOException
{
String addr="127.0.0.1";
int port1=1000;
if (arg.length>=1) addr=arg[0];
// destination
if (arg.length>=2) port1=Integer.parseInt(arg[1]);
// receiving port
System.out.println("Using
incoming port: " + port1 +
"
Destination address : " + addr);
try
{
Socket sock1 = new Socket(addr,port1);
System.out.println("Input
: " + sock1.getInetAddress()
+ " Port : "
+ sock1.getPort());
System.out.print("Creating
Write1 Thread...");
writethread1 w1Thd = new
writethread1(sock1);
writethread2 w2Thd = new
writethread2(sock1);
w1Thd.start();
w2Thd.start();
}
catch(IOException err)
{
System.out.println(err.getMessage());
}
finally
{
System.out.println("End
of the program");
}
}
}
|