cURL / Mailing Lists / curl-library / Single Mail

curl-library

libcurl + libevent2: Stalling if no data is received/written

From: Bas Verhoeven <curl_at_bserved.nl>
Date: Fri, 20 Aug 2010 18:37:55 +0200

Hi all,

I'm kinda new in the curl world and have been fiddling with libcurl's
'multi' interface in combination with libevent a bit. I am mainly
interested in this combination because my code already uses libevent2,
yet I do not think the 'evhttp' code there is mature enough.

I found an example that seemed to cover most of the functionality
required to combine these two libraries:
http://curl.haxx.se/libcurl/c/hiperfifo.html. This code seems to work
fine with the exception of one issue that I do not directly see a
solution for: when connecting to a host that never responds libcurl
never closes the connection/request.

Example:

$ ./hiperfifo
Creating named pipe "hiper.fifo"
Now, pipe some URL's into > hiper.fifo

$ nc -l -v -p 1283 &
listening on [any] 1283 ...

$ echo "http://localhost:1283/" > hiper.fifo

--- nc:

connect to [127.0.0.1] from localhost [127.0.0.1] 39284
GET / HTTP/1.1
Host: localhost:1283
Accept: */*

--- hiperfifo:

Adding easy 0x87f02c0 to multi 0x87e0498 (http://localhost:1283/)
multi_timer_cb: Setting timeout to 0 ms
* About to connect() to localhost port 1283 (#0)
* Trying 127.0.0.1... * connected
* Connected to localhost (127.0.0.1) port 1283 (#0)
socket callback: s=9 e=0x87f02c0 what=OUT Adding data: OUT
> GET / HTTP/1.1
Host: localhost:1283
Accept: */*

socket callback: s=9 e=0x87f02c0 what=IN Changing action from OUT to IN
Progress: http://localhost:1283/ (0/0)

---
At this point nothing happens and libcurl keeps waiting and waiting 
until the connection is closed or data is written to it (from the 
'server' side).
Is there any way I can force it to check for timeouts? I tried calling 
"curl_multi_socket_action(..., CURL_SOCKET_TIMEOUT, 0..)" but that 
doesn't seem to help: still nothing happens.
Any help is appreciated.
Sincerely yours,
Bas Verhoeven
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2010-08-20