blob: eabb51612d25880f40a13c9e165a7e98f6a74216 (
plain)
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 com.orbekk.protobuf;
import java.net.Socket;
import java.net.UnknownHostException;
import java.io.IOException;
public class SimpleProtobufClient {
public void run() {
try {
Socket socket = new Socket("localhost", 10000);
Rpc.Request r1 = Rpc.Request.newBuilder()
.setFullServiceName("Service1")
.build();
Rpc.Request r2 = Rpc.Request.newBuilder()
.setFullServiceName("Service2")
.build();
r1.writeDelimitedTo(socket.getOutputStream());
r2.writeDelimitedTo(socket.getOutputStream());
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new SimpleProtobufClient().run();
}
}
|