-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathServer.java
34 lines (28 loc) · 960 Bytes
/
Server.java
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
28
29
30
31
32
33
34
//main Server
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
public class Server {
//Server will be listing to incoming connections on port 2000
public static final int BASE_PORT = 2000;
public static void main(String[] args) {
new StockDB();
new OfferDB();
FirstDisplayControl guiControl = new FirstDisplayControl();
Thread guiThread = new Thread(guiControl);
guiThread.start(); //server thread start
Server server = new Server();
try {
server.serverLoop();
} catch (IOException e) {
}
}
public void serverLoop() throws IOException {
ServerSocket serverSocket = new ServerSocket(BASE_PORT);
while (true) {
Socket socket = serverSocket.accept();
Client newClient = new Client(socket);
newClient.startThread();
}
}
}