-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentServer.java
More file actions
34 lines (30 loc) · 866 Bytes
/
StudentServer.java
File metadata and controls
34 lines (30 loc) · 866 Bytes
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
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
public class StudentServer implements Runnable
{
@Override
public void run()
{
Classroom classroom = new Classroom();
final int SBAP_PORT = 8898;
ServerSocket server = null;
try
{
server = new ServerSocket(SBAP_PORT);
System.out.println("Waiting for clients to connect...");
while (true)
{
Socket s = server.accept();
System.out.println("Client connected.");
StudentService service = new StudentService(s, classroom);
Thread t = new Thread(service);
t.start();
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
}