-
Notifications
You must be signed in to change notification settings - Fork 0
/
BlaBlaReceiver.java
35 lines (28 loc) · 1.01 KB
/
BlaBlaReceiver.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
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
public class BlaBlaReceiver
{
public static void main(String[] args)
{
try {
ServerSocket ss = new ServerSocket(4020);
for(;;) {
try{
Socket client = ss.accept();
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
String line;
while((line = in.readLine()) != null)
System.out.println(line+" received");
client.close();
} catch (Exception e) {
System.out.print("An unexpected exception has been thrown inside the strange for loop : " + e.getMessage());
}
}
} catch (Exception e) {
System.out.print("An unexpected exception has been thrown : " + e.getMessage());
}
}
}