xref: /aosp_15_r20/external/grpc-grpc/examples/python/uds/README.md (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1# Unix Domain Socket Example in gRPC Python
2
3## Check Our Guide First
4
5For knowing the basics of gRPC Python and the context around the helloworld example, please checkout our gRPC Python [Quick Start guide](https://grpc.io/docs/languages/python/quickstart).
6
7## Overview
8
9This example demonstrate how gRPC Python can utilize the gRPC Name Resolution mechanism to specify UDS address for clients and servers. The gRPC Name Resolution mechanism is documented at https://github.com/grpc/grpc/blob/master/doc/naming.md.
10
11Specifically, this example will bind the server to the following UDS addresses, and use clients to connect to them:
12
13* `unix:path`: setting the unix domain socket path relatively or absolutely
14* `unix://absolute_path`: setting the absolute path of the unix domain socket
15
16## Prerequisite
17
18The Python interpreter should have `grpcio` and `protobuf` installed.
19
20## Running The Example
21
22Starting the server:
23
24```
25$ python3 greeter_server.py
26INFO:root:Server listening on: unix:helloworld.sock
27INFO:root:Server listening on: unix:///tmp/helloworld.sock
28...
29```
30
31```
32$ python3 async_greeter_server.py
33INFO:root:Server listening on: unix:helloworld.sock
34INFO:root:Server listening on: unix:///tmp/helloworld.sock
35...
36```
37
38Connecting with a client:
39
40```
41$ python3 greeter_client.py
42INFO:root:Received: Hello to unix:helloworld.sock!
43INFO:root:Received: Hello to unix:///tmp/helloworld.sock!
44```
45
46```
47$ python3 async_greeter_client.py
48INFO:root:Received: Hello to unix:helloworld.sock!
49INFO:root:Received: Hello to unix:///tmp/helloworld.sock!
50```
51