-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRPCClient.java
38 lines (37 loc) · 1.15 KB
/
RPCClient.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
36
37
38
package demo2;
import java.io. *;
import java.net. *;
class RPCClient
{
RPCClient()
{
try
{
InetAddress ia = InetAddress.getLocalHost();
DatagramSocket ds = new DatagramSocket();
DatagramSocket ds1 = new DatagramSocket(1300);
System.out.println("\nRPC Client\n");
System.out.println("Enter method name and parameter like add 3 4\n");
while(true)
{
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
String str=br.readLine();
byte b[]=str.getBytes();
DatagramPacket dp=new DatagramPacket(b,b.length,ia,1200);
ds.send(dp);
dp=new DatagramPacket(b,b.length);
ds1.receive(dp);
String s=new String(dp.getData(),0,dp.getLength());
System.out.println("\nResult= "+ s + "\n");
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
new RPCClient();
}
}