forked from deepdalsania/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTCPClient.java
More file actions
34 lines (26 loc) · 813 Bytes
/
TCPClient.java
File metadata and controls
34 lines (26 loc) · 813 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
package netpck;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
public class TCPClient {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
Socket s = new Socket("127.0.0.1" , 1000);
BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
System.out.println("<< Client Side >> ");
int a = Integer.parseInt(br.readLine());
int b = Integer.parseInt(br.readLine());
if (a > b) {
System.out.println("Subtraction of " + a + " and " + b + " is : "+(a-b));
}else{
System.out.println("Addition of" + " " + a + " " + "and" + " " + b + " " + "is : "+(a+b));
}
br.close();
s.close();
}
}