problems with event loop

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 UTC