connecting-libcurl-and-libuv

I just followed an example how to make libcurl and libuv working together. I removed usage of global variables and tested the performance by downloading (not writing to disk) 4.4GB file. It works great. It is comparable to my experience with completion ports on Windows.

libcurl: 7.66.0
libuv: 1.33.1
url: http://saimei.ftp.acc.umu.se/debian-cd/current-live/amd64/iso-hybrid/debian-live-10.2.0-amd64-lxqt.iso
code: 200

real	2m37,210s
user	0m2,297s
sys	0m6,527s

The source code of my playground: https://github.com/amacal/peak/tree/5810adf59a026fc5f630e57791fc463f0452701c

recovering-c-skills

I did not use C for about 15 years. I did never program in C at work. Recently I felt I want to satisfy my low level programming needs. I started with preparing my vim environment, wrote Makefile and simple usage of the libcurl library.

#include <stdio.h>
#include <curl/curl.h>

size_t on_write(char *ptr, size_t size, size_t nmemb, void *userdata) {
  return nmemb;
}

int on_progress(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) {
  printf("total %zu, now %zu\n", dltotal, dlnow);
  return 0;
}

int main(int argc, char** argv) {
  CURL *easy_handle = curl_easy_init();

  curl_easy_setopt(easy_handle, CURLOPT_NOPROGRESS, 0);
  curl_easy_setopt(easy_handle, CURLOPT_URL, "https://example.com/");

  curl_easy_setopt(easy_handle, CURLOPT_WRITEFUNCTION, on_write);
  curl_easy_setopt(easy_handle, CURLOPT_XFERINFOFUNCTION, on_progress);

  curl_easy_perform(easy_handle);
  curl_easy_cleanup(easy_handle);

  return 0;
}

echo server

I am trying to write quite complex and scalabe network application using only ANSI C and WinAPI to gain a lot of performance. I am not ready to do it in one iteration. The first step was just to create simple echo server. The solution was implemented in about 4 hours. It uses only single thread, but it is very concurrent thanks to Windows IOCP.

Souce Code: GitHub
Windows IOCP: Documentation