Do we have any examples to use grpc in C

7,294 views
Skip to first unread message

yy...@pivotal.io

unread,
Jan 26, 2016, 6:42:53 PM1/26/16
to grpc.io
Hi guys,

How to use grpc in C?

From thread history, the suggestion is to use C++. Understood this, while we need to use grpc in C as our existing code base is C.

Is it good to wrap grpc code in a shared library for our use case and call it from C? 

Or would suggest to use the low level C API with limited functionality?

Thanks a lot!

Nicolas Noble

unread,
Feb 2, 2016, 7:11:14 PM2/2/16
to yy...@pivotal.io, grpc.io
Right now we don't have any example for using the C core directly, no. The reason being, the C core API is pretty rough. Ideally, we'd want to write some helper functions similar to what we have in the C++ layer, but we haven't gotten to that just yet.

I would suggest reading the C++ API layer, and see if you could use that as an example of how to use the C core directly. But that's going to be pretty rough, be warned.

--
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+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/cb7be858-f25b-4583-998b-b0ca0d75f248%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yandong Yao

unread,
Feb 2, 2016, 8:16:16 PM2/2/16
to Nicolas Noble, grpc.io
Thanks a lot, Nicolas!

So how about encapsulate all functionalities using C++, create a shared library using tricks at https://isocpp.org/wiki/faq/mixing-c-and-cpp, then call C++ grpc code from C code?  Do you see any potential problems?

Regards,
Yandong
--
Best Regards,
Yandong

Nicolas Noble

unread,
Feb 3, 2016, 2:35:49 AM2/3/16
to Yandong Yao, grpc.io
That... will work, sure. That wouldn't be pretty, but it'll work.

Yandong Yao

unread,
Feb 3, 2016, 3:09:09 AM2/3/16
to Nicolas Noble, grpc.io
Thanks Nicolas!
--
Best Regards,
Yandong

kpele...@gmail.com

unread,
Apr 11, 2017, 1:02:53 PM4/11/17
to grpc.io, yy...@pivotal.io
Hello,

I was wondering if there is an update on this subject. Is it possible to use gRPC with C? Thank you.

Regards,
Kostas

Craig Tiller

unread,
Apr 11, 2017, 2:00:12 PM4/11/17
to kpele...@gmail.com, grpc.io, yy...@pivotal.io
Juniper has a library that might help you: https://github.com/juniper/grpc-c


--
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+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.

Kostas

unread,
Apr 12, 2017, 8:29:47 AM4/12/17
to Craig Tiller, grpc.io, yy...@pivotal.io
Grpc-c seems to be what I am looking for.

There are some build issues at the moment (it's still pre-alpha according to the developers) but it's definitely something to keep an eye on. Thanks Craig! :-)

Regards,
Kostas

On 11 April 2017 at 18:59, Craig Tiller <cti...@google.com> wrote:
Juniper has a library that might help you: https://github.com/juniper/grpc-c


On Tue, Apr 11, 2017 at 10:02 AM <kpele...@gmail.com> wrote:
Hello,

I was wondering if there is an update on this subject. Is it possible to use gRPC with C? Thank you.

Regards,
Kostas


On Tuesday, 26 January 2016 23:42:53 UTC, yyd...@gmail.com wrote:
Hi guys,

How to use grpc in C?

From thread history, the suggestion is to use C++. Understood this, while we need to use grpc in C as our existing code base is C.

Is it good to wrap grpc code in a shared library for our use case and call it from C? 

Or would suggest to use the low level C API with limited functionality?

Thanks a lot!

--
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+unsubscribe@googlegroups.com.

ajhai

unread,
Apr 12, 2017, 5:16:06 PM4/12/17
to grpc.io, cti...@google.com, yy...@pivotal.io, kpele...@gmail.com
Hi Kostas,

 I'm one of the developers of grpc-c. We will be pushing changes to grpc-c hopefully towards end of this month and they should bring this repo to alpha state where people can start trying it out easily.

Thanks,
Ajay


On Wednesday, April 12, 2017 at 5:29:47 AM UTC-7, Kostas wrote:
Grpc-c seems to be what I am looking for.

There are some build issues at the moment (it's still pre-alpha according to the developers) but it's definitely something to keep an eye on. Thanks Craig! :-)

Regards,
Kostas
On 11 April 2017 at 18:59, Craig Tiller <cti...@google.com> wrote:
Juniper has a library that might help you: https://github.com/juniper/grpc-c


On Tue, Apr 11, 2017 at 10:02 AM <kpele...@gmail.com> wrote:
Hello,

I was wondering if there is an update on this subject. Is it possible to use gRPC with C? Thank you.

Regards,
Kostas


On Tuesday, 26 January 2016 23:42:53 UTC, yyd...@gmail.com wrote:
Hi guys,

How to use grpc in C?

From thread history, the suggestion is to use C++. Understood this, while we need to use grpc in C as our existing code base is C.

Is it good to wrap grpc code in a shared library for our use case and call it from C? 

Or would suggest to use the low level C API with limited functionality?

Thanks a lot!

--
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+u...@googlegroups.com.

Kostas

unread,
Apr 13, 2017, 12:30:34 PM4/13/17
to ajhai, grpc.io, cti...@google.com, yy...@pivotal.io
Hi Ajay,

This is very good news, thanks for letting me know. Looking forward to trying the alpha code.

Regards,
Kostas
Message has been deleted
Message has been deleted

nikitan...@gmail.com

unread,
Oct 25, 2017, 8:07:27 AM10/25/17
to grpc.io
Hi Ajay,

Could you please point me to the C implementation of gRPC? I am trying to compile the grpc implementation from github but it looks broken. Also pointer to the documentation which will cover the QuickStart and developer reference.

Thanks in advance.

Regards,
Nikita

ajhai

unread,
Oct 25, 2017, 5:51:27 PM10/25/17
to grpc.io
Hi Nikita,

 You can find the project at https://github.com/juniper/grpc-c. You will need gRPC v1.3.0 and protobuf 3. Look at README and examples/ for usage. Please note that this library is still pre alpha.

Thanks,
Ajay

nikitan...@gmail.com

unread,
Oct 30, 2017, 6:23:06 AM10/30/17
to grpc.io
Hi Ajay,

I tried compiling the Juniper C implementation for gRPC but could not get through. I have posted the issue on github repository. Also I want to replace protoc-C by nanoPB to have a C implementation of the entire stack. Have you tried that? Are you known of any repository which has implemented gRPC on top of HTTP2 and proto/json in C.

Thank you!

ajhai

unread,
Oct 31, 2017, 9:46:27 PM10/31/17
to grpc.io
Can you check the thread at https://github.com/Juniper/grpc-c/issues/19 ? What is the version of protobuf you have installed on your Mac? I haven't tried using nanopb. It was tried before though directly with grpc. Look at https://github.com/grpc/grpc/pull/7670 and https://github.com/grpc/grpc/pull/7531 .

Thanks,
Ajay

Prashant Shubham

unread,
Aug 20, 2018, 6:09:42 AM8/20/18
to grpc.io
Can anyone guide how to write C wrapper class for grpc?  

qimi...@gmail.com

unread,
Jan 8, 2020, 4:40:39 AM1/8/20
to grpc.io
Hi Ajay,
I got a proble while trying to run the example, 
client code like this:
for(i = 0; i < 1000; i ++)
   foo__greeter__say_hello(...)
}

after running hundreds of times, the server crash ,  "doube free" .
do you have any idea about this problem?

Thanks a lot!

Ashique C K

unread,
May 4, 2021, 5:58:13 AM5/4/21
to grpc.io
Hi,
By using this command protoc --c_out=. foo.proto, it will generate foo.pb-c.c, foo.pb-c.h fiiles.
What is the command to generate grpc file too. For that we need grpc C plugin right ?
From where I can get that ?
Reply all
Reply to author
Forward
0 new messages