-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
30 lines (22 loc) · 866 Bytes
/
Main.java
File metadata and controls
30 lines (22 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
import java.io.*;
import java.net.*;
public class Main {
public static void main(String[] args) {
try
{
ServerSocket serverSocket = new ServerSocket(80); //create a server socket object
boolean isstop = false;
while(!isstop) //while server is not stopped
{
Socket clientSocket = serverSocket.accept();
System.out.println("Client " + clientSocket.getInetAddress().getHostAddress() + " is connected");//print client
ClientThread clientThread = new ClientThread(clientSocket);//creata a new thread for each client
clientThread.start();
}
}
catch (Exception e)
{
System.out.println(e.toString());
}
}
}