W3C home > Mailing lists > Public > www-lib@w3.org > January to March 2002

problems with event loop

From: Pau Aliagas <linuxnow@wanadoo.es>
Date: Wed, 30 Jan 2002 10:56:02 +0100 (CET)
To: www-lib@w3.org
Message-ID: <Pine.LNX.4.44.0201301042240.13543-100000@pau.intranet.ct>

I need to build a daemon that will fetch URLs in asynchronus mode, that is
using events and callbacks, on request. The requests will be coming
through a socket as I've seen that's been suggested in some threads.

So I:
-fork a daemon
-create an async client
 * HTProfile_newNoCacheClient
 * create callbacks HTPrint_setCallback
 * add filters to handle termination HTNet_addAfter
-create a new request like in eventloop
 * HTRequest_new()
 * HTEvent_new(socket_parser, me, HT_PRIORITY_MAX, -1)
   and register the callback for the socket event
-create a socket
-bind it to a port
-register the socket HTEvent_register(sockfd, HTEvent_READ, grabber->socket_event)
-and finally HTEventList_newLoop()

Here I expect that when I get a connection and get the URL requested 
through that socket. But recvfrom always fails.

socket_parser (SOCKET s, void *param, HTEventType type) {
...
	if (recvfrom(s, buf, 255, 0, NULL, NULL) < 0) {
		return HT_ERROR;
	}
}

I always hit this return HT_ERROR.

Any ideas of what could be happening? Any pointer to some other example or 
documentaion?

I've been browsing through the lists but haven't found an answer to my 
question.

Thanks
Pau
Received on Wednesday, 30 January 2002 04:56:37 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:40 GMT