Client.java 691 Bytes
Newer Older
Michele Fiori's avatar
Michele Fiori committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
package theatre;

import java.io.*;
import java.net.*;

class Client {
    public static void main(String[] argv) throws Exception {
        String response;

        System.out.println("Booking a seat...");

        Socket clientSocket = new Socket("localhost", 9876);

        BufferedReader inFromServer =
                new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));

        response = inFromServer.readLine();

        if(response.equals("-1")) {
            System.out.println("NO AVAILABLE SEATS");
        } else {
            System.out.println("RESERVED SEATS: " + response);
        }

        clientSocket.close();
    }
}