1 import java.io.IOException;
2 import java.net.ServerSocket;
3 import java.net.Socket;
4
5 /**
6 A server that executes the Simple Bank Access Protocol.
7 */
8 public class BankServer
9 {
10 public static void main(String[] args) throws IOException
11 {
12 final int ACCOUNTS_LENGTH = 10;
13 Bank bank = new Bank(ACCOUNTS_LENGTH);
14 final int SBAP_PORT = 8888;
15 ServerSocket server = new ServerSocket(SBAP_PORT);
16 System.out.println("Waiting for clients to connect...");
17
18 while (true)
19 {
20 Socket s = server.accept();
21 System.out.println("Client connected.");
22 BankService service = new BankService(s, bank);
23 Thread t = new Thread(service);
24 t.start();
25 }
26 }
27 }
28
29
30
31
32
33
34
35