Subversion Repositories programming

Rev

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

Rev 187 Rev 188
Line 15... Line 15...
15
import java.net.*;
15
import java.net.*;
16
 
16
 
17
public class P1Server
17
public class P1Server
18
{
18
{
19
    public static final int portNumber = 1337;
19
    public static final int portNumber = 1337;
-
 
20
    public static final String exitSeq = "QUIT";
20
 
21
 
21
    /**
22
    /**
22
     * Method: main()
23
     * Method: main()
23
     * Purpose: This method creates a listening socket on port 1337 and
24
     * Purpose: This method creates a listening socket on port 1337 and
24
     * accepts the first connection made to it. It then echoes back anything
25
     * accepts the first connection made to it. It then echoes back anything
Line 63... Line 64...
63
 
64
 
64
        /* Read input and echo back to output */
65
        /* Read input and echo back to output */
65
        while ((inputLine = in.readLine()) != null)
66
        while ((inputLine = in.readLine()) != null)
66
        {
67
        {
67
            /* If we recieve a message to quit, do so. */
68
            /* If we recieve a message to quit, do so. */
68
            if (inputLine.equals ("QUIT"))
69
            if (inputLine.equals (exitSeq))
69
                break;
70
                break;
70
            
71
            
71
            /* Echo back what we recieved */
72
            /* Echo back what we recieved */
72
            out.println (inputLine);
73
            out.println (inputLine);
73
        }
74
        }