3

I have a client that manages the socket connection on its own (actually using libevent's bufferevent). Now, I'd like to use libcurl to produce and send HTML GET requests on that socket. I'm done with this part by feeding libcurl, my already opened socket using OPENSOCKET_FUNCTION option.

But my problem is now that both libevent and libcurl are listening on the socket and sometimes it's libevent who answers to the socket when it has data, and sometimes it's libcurl.

Is there way to tell libcurl to just produce and send the GET request for the url, but not to listen on socket so I can take the matters in my hand after libcurl wrote the url in the socket?

Obviously, I'm using curl_multi interface for non-blocking sockets, otherwise curl_easy_perform doesn't return 'til it receives its answer.

I don't want to let the bufferevent listener go and stay with libcurl, because it's a multi-protocol program, and I'm implementing the http part of it. Other protocols don't have the luxury of using libcurl, so I need to keep the bufferevent structure.

Gaffi
  • 4,307
  • 8
  • 43
  • 73
vmon
  • 33
  • 3

1 Answers1

1

You're probably looking for the curl_multi_socket_action() function. An example use of that function together with libevent is provided by curl in the hiperfifo.c source.

Daniel Stenberg
  • 54,736
  • 17
  • 146
  • 222
  • I did the following: 1. Only activated EV_WRITE in creation of event: "event* write_url_event = event_new(the_event, the_socket, EV_WRITE, curl_socket_event_cb, arg);" 2. Disabled libevent write callback: "bufferevent_disable(conn->buffer, EV_WRITE);" 3. And when the event call back gets called, I called curl_multi_socket_action() only with CURL_CSELECT_OUT: "rc = curl_multi_socket_action(curl_multi_handle, fd, CURL_CSELECT_OUT, &curl_running_handle);" Still I'm losing some packets that are sent by the peer on the socket. I never receive them on otherside. Could it be a bug with libcurl? – vmon Aug 26 '12 at 07:13
  • This is not a libcurl forum, ask detailed questions on the libcurl list. It could be a bug in the lib, could be a bug in your app. Or both. The general method is still as I have described and which is documented. – Daniel Stenberg Aug 26 '12 at 16:51
  • Sorry for flip floping on the acceptance. It actually worked perfectly. The problem was that the terminal that I was using was not honest in printing out all of stderr and as such, I thought I'm losing packets. – vmon Aug 31 '12 at 19:17