-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathServer.java
More file actions
43 lines (32 loc) · 786 Bytes
/
Server.java
File metadata and controls
43 lines (32 loc) · 786 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
35
36
37
38
39
40
41
42
43
package java_ssp;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
public class Server {
public static void main(String[] args) {
// TODO Auto-generated method stub
ServerSocket listener = null;
try {
listener = new ServerSocket(1234);
while(true)
{
Socket socket = listener.accept();
ServerThread st = new ServerThread(socket);
st.start();
System.out.println(socket.getInetAddress()+"´Ô ÀÔÀå");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
try {
if(listener!=null)
listener.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}