Subversion Repositories programming

Rev

Rev 221 | Rev 224 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 221 Rev 223
Line 8... Line 8...
8
 * Date Last Modified: 2006-02-15
8
 * Date Last Modified: 2006-02-15
9
 *
9
 *
10
 * Purpose: //FIXME
10
 * Purpose: //FIXME
11
 ******************************************************************************/
11
 ******************************************************************************/
12
 
12
 
-
 
13
import java.net.*;
-
 
14
import java.io.*;
-
 
15
 
-
 
16
public class P3_Client
-
 
17
{
-
 
18
    private static IPAddr ip;
-
 
19
    private static String hw;
-
 
20
 
-
 
21
    private static final String hostName = "localhost";
-
 
22
    private static final int portNumber = 1337;
-
 
23
 
-
 
24
    public static void main (String[] args) throws Exception
-
 
25
    {
-
 
26
        Socket socket = null;
-
 
27
        PrintWriter out = null;
-
 
28
        BufferedReader in = null;
-
 
29
        BufferedReader kbd = null;
-
 
30
        String s = new String();
-
 
31
        boolean running = true;
-
 
32
 
-
 
33
        try
-
 
34
        {
-
 
35
            socket = new Socket (hostName, portNumber);
-
 
36
            out = new PrintWriter (socket.getOutputStream(), true);
-
 
37
            in = new BufferedReader (new InputStreamReader (
-
 
38
                                         socket.getInputStream()));
-
 
39
            kbd = new BufferedReader (new InputStreamReader (System.in));
-
 
40
        }
-
 
41
        catch (UnknownHostException e)
-
 
42
        {
-
 
43
            System.err.printf ("Can't resolve hostname: %s\n", hostName);
-
 
44
            System.exit (1);
-
 
45
        }
-
 
46
        catch (IOException e)
-
 
47
        {
-
 
48
            System.err.printf ("Couldn't get I/O for the connection to: %s\n", hostName);
-
 
49
            System.exit (2);
-
 
50
        }
-
 
51
 
-
 
52
        System.out.print ("Please type your Hardware Address: ");
-
 
53
        hw = kbd.readLine();
-
 
54
 
-
 
55
        // Send Hardware Address
-
 
56
        out.printf ("req IP %s\n", hw);
-
 
57
 
-
 
58
        while (running)
-
 
59
        {
-
 
60
            s = in.readLine();
-
 
61
            System.out.println (s);
-
 
62
 
-
 
63
            if (s.equals("IP Lease Time Expired"))
-
 
64
                running = false;
-
 
65
        }
-
 
66
 
-
 
67
        System.out.println ("Exiting");
-
 
68
 
-
 
69
        out.close();
-
 
70
        in.close();
-
 
71
        socket.close();
-
 
72
    }
-
 
73
}
-
 
74
 
-
 
75
 
-
 
76