Advertisement
MdSadmanSiraj

requestor_host.c

Jul 14th, 2022
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <curl/curl.h>
  3.  
  4. #define OK 0
  5. #define INIT_ERR 1
  6. #define REQ_ERR 2
  7.  
  8. #define URL "http://10.0.2.15:8000"
  9.  
  10. int main(void) {
  11.     CURL *curl;
  12.     CURLcode res;
  13.  
  14.     curl = curl_easy_init();
  15.     if (curl) {
  16.         curl_easy_setopt(curl, CURLOPT_URL, URL);
  17.         curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  18.         res = curl_easy_perform(curl);
  19.         if(res != CURLE_OK) {
  20.             return REQ_ERR;
  21.             }
  22.         curl_easy_cleanup(curl);
  23.         } else {
  24.         return INIT_ERR;
  25.         }
  26.     return OK;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement