本文介绍了是否可以在C / C ++中执行此操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,之前我已经问了一个类似的问题,但还没有解决,在C#中我可以简单地创建一个WebClient并将一个字符串上传到我的媒体Web服务器并读取结果数据(JSON) (解析json时没有问题)



 WebClient client =  new  WebClient(); 
字符串 RawJson = client.UploadString( 本地主机:9000 / jsonrpc.js,MYDATA);
// 已完成工作。





谷歌搜索,直到我脸上的几个蓝色阴影没有帮助我,由于各种原因我需要在C或C ++中执行此操作并在Android / Linux盒子上运行(主要是Android虽然)由于Android的限制我不能使用Casablanca或libcurl所以需要在没有第三方库的情况下这样做,我知道如何使用套接字连接到localhost:9000,但不知道如何与jsonrpc.js进行通信 - 我假设我必须编写标题信息以及我不知道的所有黑暗的东西 - 任何帮助实现这一点都会很棒 - 一旦我知道如何发送和接收数据我将会启动并运行它是第一步我无法弄清楚(顺便说一下这是个人家居项目)



我尝试过的事情:



谷歌搜索,直到我脸上有几种蓝色阴影

解决方案

在C#中你的生活很简单 - 有人给你写了一个类来处理你和web服务器之间的所有数据流...

当然原来的C ++库没有这样的类,但是幸运的是有些人认为你可能需要一个...

]



(当然你可以使用标准的流媒体库编写自己的解决方案,但这可能有点费时)


Hi all, I've asked a similar question before but still haven't got it solved yet, in C# I can simply create a WebClient and upload a string to my media web server and read the resultant data (JSON) thus ( I don't have a problem parsing the json )

 WebClient client = new WebClient();
 String RawJson = client.UploadString("localhost:9000/jsonrpc.js",mydata);
// Job done.



Googling until I'm several shades of blue in the face has not helped me, for various reasons I need to do this in C or C++ and run it on an Android / Linux box ( mainly Android though ) Because of limitations in Android I can't use Casablanca or libcurl so need to do this without third party libraries , I know how to connect to localhost:9000 using sockets, but not how to then communicate with jsonrpc.js - I assume I have to write header information and all the dark stuff I don't know about - any help in achieving this would be fantastic - once I know how to send and receive the data I'll be up and running it's the first step I can't figure out ( this is a personal home project by the way )

What I have tried:

Googling until I'm several shades of blue in the face

解决方案
In C# your life is easy - someone wrote you a class that handle all the streaming of data between you and the web server...
Of course the original C++ libraries have no such class, but fortunately there are some who think you may need one...
CkUpload C++ Reference Documentation[^]

(Of course you can go and use the standard streaming libraries to write your own solution, but it may be a bit time consuming)


这篇关于是否可以在C / C ++中执行此操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 04:26