Hi,

Any one tested AF_UNIX socket file descriptor on gRPC C++? I have issue 
connecting the client to server. and also I am not sure whether server 
started with file descriptor or not. appreciated if any one give some 
points in that front.

I changed hello world example to following:

server.cpp:


int socketFd = socket( AF_UNIX, SOCK_STREAM , 0);
 
  struct sockaddr_un server_address;
  server_address.sun_family = AF_UNIX;
    strcpy(server_address.sun_path, "server_socket");
    int server_len = sizeof(server_address);
    bind(socketFd, (struct sockaddr *)&server_address, server_len);
  
  std::string server_address2("127.0.0.1:50051");
  GreeterServiceImpl service;


  ServerBuilder builder;
  builder.AddListeningPort(server_address2, grpc::InsecureServerCredentials
());
   builder.RegisterService(&service);
 
  std::unique_ptr<Server> server(builder.BuildAndStart());


  grpc::AddInsecureChannelFromFd(server.get(), socketFd);
 
  server->Wait();




  client.cpp


  int socketFd = socket( AF_UNIX, SOCK_STREAM, 0);
    struct sockaddr_un address;
    address.sun_family = AF_UNIX;
    strcpy(address.sun_path, "server_socket");
    int len = sizeof(address);
    int st = connect( socketFd, (struct sockaddr *)&address, sizeof(address) 
);   


    std::cout << "st " << st << std::endl;
  GreeterClient greeter(grpc::CreateInsecureChannelFromFd("localhost", 
socketFd));


  if I change the address family to AF_INET then client gets the response 
from server.

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/a3a3ff00-c484-4fb8-b8ee-2522fbaf6309%40googlegroups.com.

Reply via email to