Skip to content

Instantly share code, notes, and snippets.

@anhldbk
anhldbk / tor-raw.cpp
Created December 6, 2016 02:38
Working with Tor (C/C++)
// g++ -lstdc++ -Wno-write-strings fetch.cpp -o fetch
#ifdef _WIN32 // Windows
#include <winsock2.h>
#include <ws2tcpip.h>
#define MSG_NOSIGNAL 0
#else // Linux + Mac
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
@whoshuu
whoshuu / curlget.cpp
Created March 31, 2015 06:44
Example libcurl GET request
#include <curl/curl.h>
#include <string>
size_t writeFunction(void *ptr, size_t size, size_t nmemb, std::string* data) {
data->append((char*) ptr, size * nmemb);
return size * nmemb;
}
int main(int argc, char** argv) {
auto curl = curl_easy_init();
// Answer to http://github.com/ry/http-parser/issues/#issue/1
// UNTESTED
struct line {
char *field;
size_t field_len;
char *value;
size_t value_len;
};