| 1 |
## Data transmission demo for using gRPC in Python |
| 2 |
|
| 3 |
Four ways of data transmission when gRPC is used in Python. [Official Guide](<https://grpc.io/docs/guides/concepts/#unary-rpc>) |
| 4 |
|
| 5 |
- #### unary-unary |
| 6 |
|
| 7 |
In a single call, the client can only send request once, and the server can only respond once. |
| 8 |
|
| 9 |
`client.py: simple_method` |
| 10 |
|
| 11 |
`server.py: SimpleMethod` |
| 12 |
|
| 13 |
- #### stream-unary |
| 14 |
|
| 15 |
In a single call, the client can transfer data to the server an arbitrary number of times, but the server can only return a response once. |
| 16 |
|
| 17 |
`client.py: client_streaming_method` |
| 18 |
|
| 19 |
`server.py: ClientStreamingMethod` |
| 20 |
|
| 21 |
- #### unary-stream |
| 22 |
|
| 23 |
In a single call, the client can only transmit data to the server at one time, but the server can return the response many times. |
| 24 |
|
| 25 |
`client.py: server_streaming_method` |
| 26 |
|
| 27 |
`server.py: ServerStreamingMethod` |
| 28 |
|
| 29 |
- #### stream-stream |
| 30 |
|
| 31 |
In a single call, both client and server can send and receive data |
| 32 |
to each other multiple times. |
| 33 |
|
| 34 |
`client.py: bidirectional_streaming_method` |
| 35 |
|
| 36 |
`server.py: BidirectionalStreamingMethod` |
| 37 |
|