cURL Mailing List Monthly Index Single Mail
curl-library Mailing List Archives
Re: a question about using libcurl two threads
As known, if use curl_multi_fdset(), it must do curl_multi_add_handle() to prepare the multi_handle handle.
That means i must add all the simple handle before i can use curl_multi_add_handle().
But that is a big difference to my module's mechanism.
My module's message queue is keep receiving the messges. And I have to dequeue the messages from the queue
serially.That means I do not know what the next message in the queue is when i am dequeuing the current
message.So i only can add a handle to multi_handle once a time. So it is impossible for me to dequeue all
the messages and all all of them to the multi_handle since who knows no new message arrived or on the way.
My purpose is like this:
Thread 1 do 1-3 steps and Thread 2 do the 4th step
step1: when a message is dequeue from the my message queue, I will curl_easy_init() a new handle
step2: send the message to HTTP server( but do not use callback function to get the response)
step3: get the corresponding fd of the connection between my module and HTTP server and add
the fd to the fdread fd_set.
step4: in a while(1) cycle, select the fdread fd_set every the timeout value interval.If
select() find data arrives and FD_ISSET() think the data is readable, i will read out
the data and do some processing later.
I think curl sure can do the job, but i do can not adopt the functions privides by curl present's examples.
----- Original Message -----
From: "Daniel Stenberg" <daniel-curl_at_haxx.se>
To: "libcurl development" <curl-library_at_cool.haxx.se>
Sent: Wednesday, September 08, 2004 4:23 PM
Subject: Re: a question about using libcurl two threads
> On Wed, 8 Sep 2004, Andy hobbs wrote:
> > You can use curl_multi_fdset() to get the sockets for a connection, then put
> > them into nonblocking mode and call select your self on them.
> They're already set to non-blocking mode by libcurl.
> Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
> Dedicated custom curl help for hire: http://haxx.se/curl.html
>On Wed, 2004-09-08 at 03:36, 黄志军 wrote:
> Now i am testing to use libcurl(curl-7.12.0 ) and i am wonder whether
> libcurl can support the followings,
> anyone presents me explanation or example is appreciated.
> I want to design a communication module to transfer messages between
> a TCP side and a http server.
> I will create two threads. One thread's function is to send the
> message which got from the TCP side to the http server
> whenever my module got them. The other thread will keep receiving the
> response messages from the http server.
> So , i wonder whether libcurl api can support the nonblocking sending
> and use the similar method like select
> to receive the response message from the httpserver.
> I want to adopt this kind of mechanism since maybe there are many TCP
> messages got at the same time
> and my module should send them out to the corresponding HTTP server
> one by one without blocking to
> receive any of the response. Then i use another thread to do the
> receiving job which avoid blocking
> others' sending when any one or more of the HTTP server response slow
> or timeout.
Received on 2004-09-09
These mail archives are generated by hypermail.
Page updated November 12, 2010.
File upload with ASP.NET
web site info