forked from asdfghjkai/STS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
STSServer.java
47 lines (39 loc) · 1.03 KB
/
STSServer.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
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.net.*;
import java.io.*;
public class STSServer
{
protected ServerSocket STSSocket = null;
public StockMarket mySM;
public STSServer()
{
}
public void initSTS()
{
System.out.println("StockMarket thread started.");
Thread t1 = new Thread(mySM.getStockMarket());
t1.start();
}
public void listenForClients()
{
try
{
STSSocket = new ServerSocket(5000);
while(true)
{
System.out.println("Listening for connections from Client.\n");
new ClientConnect(STSSocket.accept(), mySM.getStockMarket());
}
}
catch(IOException e)
{
System.out.println("Error in setting up socket " + e);
System.exit(1);
}
}
public static void main(String [] args)
{
STSServer mySTS = new STSServer();
mySTS.initSTS();
mySTS.listenForClients();
}
}