forked from deepdalsania/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTCP_Server.java
More file actions
30 lines (25 loc) · 749 Bytes
/
TCP_Server.java
File metadata and controls
30 lines (25 loc) · 749 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
package netpck;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;
public class TCP_Server {
/**
* @param args
* @throws IOException
* @throws UnknownHostException
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
ServerSocket ss = new ServerSocket(150);
Socket s = ss.accept();
System.out.println("Connection Established...");
BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
System.out.println("<< Server Side >> " + "\n Received Data is : " + br.readLine());
br.close();
ss.close();
s.close();
}
}