The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#) https://grpc.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Lidi Zheng 3f2b3460a4
[Python] Add an UDS example (#29592)
3 years ago
..
.gitignore [Python] Add an UDS example (#29592) 3 years ago
README.md [Python] Add an UDS example (#29592) 3 years ago
async_greeter_client.py [Python] Add an UDS example (#29592) 3 years ago
async_greeter_server.py [Python] Add an UDS example (#29592) 3 years ago
greeter_client.py [Python] Add an UDS example (#29592) 3 years ago
greeter_server.py [Python] Add an UDS example (#29592) 3 years ago
helloworld_pb2.py [Python] Add an UDS example (#29592) 3 years ago
helloworld_pb2_grpc.py [Python] Add an UDS example (#29592) 3 years ago

README.md

Unix Domain Socket Example in gRPC Python

Check Our Guide First

For knowing the basics of gRPC Python and the context around the helloworld example, please checkout our gRPC Python Quick Start guide.

Overview

This 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.

Specifically, this example will bind the server to the following UDS addresses, and use clients to connect to them:

  • unix:path: setting the unix domain socket path relatively or absolutely
  • unix://absolute_path: setting the absolute path of the unix domain socket

Prerequisite

The Python interpreter should have grpcio and protobuf installed.

Running The Example

Starting the server:

$ python3 greeter_server.py
INFO:root:Server listening on: unix:helloworld.sock
INFO:root:Server listening on: unix:///tmp/helloworld.sock
...
$ python3 async_greeter_server.py
INFO:root:Server listening on: unix:helloworld.sock
INFO:root:Server listening on: unix:///tmp/helloworld.sock
...

Connecting with a client:

$ python3 greeter_client.py
INFO:root:Received: Hello to unix:helloworld.sock!
INFO:root:Received: Hello to unix:///tmp/helloworld.sock!
$ python3 async_greeter_client.py
INFO:root:Received: Hello to unix:helloworld.sock!
INFO:root:Received: Hello to unix:///tmp/helloworld.sock!