Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8887651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:51:45+00:00 2026-06-14T21:51:45+00:00

Background: I’m working on my first C program with the library and I need

  • 0

Background:

I’m working on my first C program with the library and I need to gather responses from each command sent to a SMTP server.

I’ve gotten as far as sending commands to the SMTP server and printing the response headers using curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, parse_head), but I’m using multi threaded options. It is not at all clear when I get a response which command it was caused by. I am assuming that they will not necessarily be received in the same order sent. Is that correct?

Making it more difficult, since the library handles some calls (like setting up the initial connection) without my explicit request, I would need to handle more headers than explicit requests. That would be predictable and repeatable, but definitely adds an extra level of complexity.

Question:

Is there a “good” way to determine exactly which command resulted in which response header using multi thread?

Also, moderately related, does the library support returning the numeric return code or do I have to manually parse that out? Looking through the library, it seems that it doesn’t. I just want to be sure.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:51:47+00:00Added an answer on June 14, 2026 at 9:51 pm

    I am assuming that they will not necessarily be received in the same order sent. Is that correct?

    Yes, it is. That’s how multithreading works.

    Is there a “good” way to determine exactly which command resulted in which response header using multi thread?

    Yes. You can set user data (context info, whatever you call it) using the CURLOPT_HEADERDATA option – this will be passed in as the 4th argument of your header function. So you can write code like this:

    CURL *hndl = curl_easy_init();
    // ... 
    curl_easy_setopt(hndl, CURLOPT_HEADERFUNCTION, parse_head);
    curl_easy_setopt(hndl, CURLOPT_HEADERDATA, some_pointer_that_identifies_the_thread);
    // ...
    
    size_t parse_head(void *buf, void *size_t sz, size_t nmemb, void *context)
    {
        // context will be the pointer identifying the thread
    }
    

    does the library support returning the numeric return code or do I have to manually parse that out?

    Yes, it does:

    long httpStatus;
    curl_easy_getinfo(hndl, CURLINFO_RESPONSE_CODE, &httpStatus);
    if (200 <= httpStatus && httpStatus < 300) {
        // HTTP 2XX OK
    } else {
        // Error (4XX, 5XX) or redirect (3XX)
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: I've wrote a small library that is able to create asp.net controls from
Background: What I need to accomplish is to remove any records in a collection
Background I am working with a monad built of a stack of transformers one
Background: Using unix, codeigniter from localhost. I'd like to run a controllers via a
Background - I want to extract specific columns from a csv file. The csv
Background I've got an NSOutlineView that shows TrainingGroup entities. Each TrainingGroup represents a folder
Background / Disclaimer First of all, please feel free to skip this entirely if
Background I have an installation of VisualSVN on a server. under this, I have
Background: I have several builds running on a Windows Server 2003 R2 machine via
Background: I'm running a Minecraft server for friends on a VPS, and I'm attempting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.