Hi, I just came across this thread trying to make c++ grpc work with unix 
sockets.
The server seems to be fine, but the client channel (just a channel) won't 
connect. I tried 
*CreateInsecureChannelFromFd but it reports: *



*E1011 16:25:27.837081744    6800 channel_connectivity.cc:127] 
grpc_channel_watch_connectivity_state called on something that is not a 
client channelCan anyone help me understand this error? *

On Thursday, January 18, 2018 at 2:10:49 AM UTC+1 apo...@google.com wrote:

> choonk@ that API exists in the C-core but is not currently exposed by the 
> C# wrapper. If this functionality is still wanted though, I suggest filing 
> a feature request issue in github or a pull request.
>
> On Wednesday, January 10, 2018 at 6:42:47 PM UTC-8, choonk...@gmail.com 
> wrote:
>>
>> Is it possible to have a gRPC C# client create its channel from an opened 
>> socket?
>>
>>
>> On Wednesday, December 27, 2017 at 5:06:17 PM UTC+8, christo...@gmail.com 
>> wrote:
>>
>>> Ok i have found how to communicate over a socket:
>>>
>>> Code of the Server Side :
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> *int main(int argc, char **argv) {//create socket        int socketFd = 
>>> socket( AF_INET, SOCK_STREAM | SOCK_NONBLOCK , 0);         HelloImpl 
>>> helloService;        std::string server_address("127.0.0.1:50051 
>>> <http://127.0.0.1:50051>");        ServerBuilder builder;        
>>> builder.AddListeningPort(server_address, 
>>> grpc::InsecureServerCredentials());        
>>> builder.RegisterService(&helloService);        std::unique_ptr<Server> 
>>> server(builder.BuildAndStart());                 
>>> grpc::AddInsecureChannelFromFd( server.get(), socketFd );        std::cout 
>>> << "listen ..." <<std::endl;        server->Wait();        std::cout << 
>>> "Server Stop " << std::endl;}*Code of the client side: 
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> *int main(int argc, char **argv) {    std::cout << "main client start" 
>>> << std::endl;    int socketFd = socket( AF_INET, SOCK_STREAM | 
>>> SOCK_NONBLOCK, 0);    struct sockaddr_in address;    address.sin_family = 
>>> AF_INET;    address.sin_addr.s_addr = INADDR_ANY;    address.sin_port = 
>>> htons(50051);    int st = connect( socketFd, (struct sockaddr *)&address, 
>>> sizeof(address) );        std::cout << "st " << st << std::endl;        
>>> std::unique_ptr<helloworld::Greeter::Stub> stub(         
>>> helloworld::Greeter::NewStub(            
>>> //grpc::CreateChannel("localhost:50051", 
>>> grpc::InsecureChannelCredentials())            
>>> //grpc::CreateChannel("127.0.0.1:8088 <http://127.0.0.1:8088>", 
>>> grpc::InsecureChannelCredentials())            
>>> grpc::CreateInsecureChannelFromFd("localhost", socketFd)        )    );    
>>>     std::this_thread::sleep_for( std::chrono::seconds(2));    ClientContext 
>>> context;    const helloworld::HelloRequest request;    
>>> helloworld::HelloReply response;    std::cout << "send SayHello" << 
>>> std::endl;    stub->SayHello( &context, request, &response );    std::cout 
>>> << "----->" <<response.message() << std::endl;}*
>>>
>>> I hope that it will help people that want to communicate over posix 
>>> Socket. It is not documented on the Grpc website.
>>>
>>>
>>>
>>> Le mardi 26 décembre 2017 17:54:46 UTC+1, christo...@gmail.com a écrit :
>>>>
>>>> Hi Leonardo,
>>>>
>>>> could you send code snippet on the way you implement the server side 
>>>> with a posix socket and the client side.
>>>>
>>>> thanks.
>>>>
>>>> Le mercredi 21 décembre 2016 14:16:16 UTC+1, Leonardo Romor a écrit :
>>>>>
>>>>> Ok, so, I simply had to BuildAndStart(), get() the pointer and 
>>>>> register the file descriptors using AddInsecureChannelFromFd.
>>>>> the filedescriptors must be obviously set as non blocking.
>>>>>
>>>>> Il giorno mercoledì 21 dicembre 2016 12:30:00 UTC+1, Leonardo Romor ha 
>>>>> scritto:
>>>>>>
>>>>>> Hello everyone,
>>>>>>
>>>>>> Dummy question regarding this: 
>>>>>> https://github.com/grpc/grpc/blob/master/include/grpc%2B%2B/server_posix.h
>>>>>>  
>>>>>> How is this supposed to be used?
>>>>>> I mean, do I have to write my own server builder? 
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> -l
>>>>>>
>>>>>

-- 
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 grpc-io+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/69288250-5c57-44f4-9264-29d4c990a10cn%40googlegroups.com.

Reply via email to