libcurl的实用例子

官方的例子:https://curl.haxx.se/libcurl/c/example.html事实上我们集成使用时希望1.非阻塞,方便随时取消2.看到进度3.逐个下载其他的暂时没啥叼用。融合官网例子,自己做的测试代码如下,改改封装可用了:#include "stdio.h"#include "stdlib.h"#include "string.h"#ifdef _WI...
摘要由CSDN通过智能技术生成

官方的例子:
https://curl.haxx.se/libcurl/c/example.html
事实上我们集成使用时希望
1.非阻塞,方便随时取消
2.看到进度
3.逐个下载

其他的暂时没啥叼用。
融合官网例子,自己做的测试代码如下,改改封装可用了:


#include "stdio.h"
#include "stdlib.h"
#include "string.h"

#ifdef _WIN32
#define WAITMS(x) Sleep(x)
#else
/* Portable sleep for platforms other than Windows. */
#define WAITMS(x)                               \ 
struct timeval wait = { 0, (x) * 1000 };      \
	(void)select(0, NULL, NULL, NULL, &wait);
#endif


#define HTTPURL "http://abc.efg.com/ddd.php"

struct MemoryStruct {
	char *memory;
	size_t size;
	size_t length;
};

static size_t
WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
	printf("WriteMemoryCallback\n");
	size_t realsize = size * nmemb;
	struct MemoryStruct *mem = (struct MemoryStruct *)use
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值