forked from deepdalsania/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTCP_Ctest.java
More file actions
29 lines (24 loc) · 743 Bytes
/
TCP_Ctest.java
File metadata and controls
29 lines (24 loc) · 743 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
package netpck;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.Socket;
import java.net.UnknownHostException;
public class TCP_Ctest {
/**
* @param args
* @throws IOException
* @throws UnknownHostException
*/
public static void main(String[] args) throws UnknownHostException, IOException {
// TODO Auto-generated method stub
Socket socket = new Socket("localhost", 654);
PrintStream ps = new PrintStream(socket.getOutputStream());
System.out.println("<<Client to server>>" + "\nEnter Your Name : ");
ps.println(new BufferedReader(new InputStreamReader(System.in)).readLine());
socket.close();
ps.flush();
ps.close();
}
}