简体   繁体   English

如何为C ++项目开发API

[英]How to develop an API for an c++ project

I have developed an crawler in c++ with curl library and as it is developed in c++ it does not has an GUI and i am planning to implement the GUI using java .I have a question how to develop an API to access it in java... 我已经在C ++中使用curl库开发了一个搜寻器,并且由于它是在c ++中开发的,因此它没有GUI,并且我打算使用Java来实现GUI。 。

for example Mongo db is written in c++ and it has API for all languages..how it access the c++ do it uses socket to communicate... 例如Mongo db是用c ++编写的,并且具有适用于所有语言的API ..它如何访问c ++并使用套接字进行通信...

You will need to write/wrap the crawler as a service and host it on a server that is listening on a port. 您将需要将搜寻器作为服务编写/包装,并将其托管在正在侦听端口的服务器上。 You might want to create a text or binary protocol whereby the clients can then talk to this service. 您可能想要创建文本或二进制协议,以便客户端可以与该服务进行对话。 Once thats established, you can write the clients in any language including Java. 一旦建立,就可以用任何语言(包括Java)编写客户端。

也许您会发现此有用: http : //java.sun.com/docs/books/jni/

也来看看Thrift

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM