You just have to build your own "state machine" to check if zmq_recv have done its job (!EAGAIN).
(And yes you can safely store that "state" on whatever in the data field).

Le 01/10/2010 03:44, Catel Anthony a écrit :
 Oups, I said something totally wrong you can keep the zmq_recv.

static void ape_zmq_read(ape_socket *client, ape_buffer *buf, size_t offset, acetables *g_ape)
    {

    zmq_recv(g_ape->co[active_fd]->data,&msg, ZMQ_NOBLOCK)

    }
    int sock;
    zmq_getsockopt(zmq_socket, ZMQ_FD, &sock, &sock_size);
    prepare_ape_socket(sock, g_ape);

    g_ape->co[sock]->fd = sock;
    g_ape->co[sock]->stream_type = STREAM_DELEGATE;

    g_ape->co[sock]->callbacks.on_read = ape_zmq_read;
    g_ape->co[sock]->callbacks.on_write = ape_zmq_write;

    events_add(g_ape->events, sock, EVENT_READ|EVENT_WRITE);

Le 01/10/2010 03:39, Catel Anthony a écrit :
 I never looked at the zmq C API but :

- You should look at there http://api.zeromq.org/zmq_recv.html function to substitute it with your own read callback.

In one word : You should exclude there socket managment to replace it with the APE one.


Le 01/10/2010 03:33, Andrew Thompson a écrit :
On Fri, Oct 01, 2010 at 03:26:22AM +0200, Catel Anthony wrote:
  Just a note in your commit.

I think that you should have used the "STREAM_DELEGATE" APE socket for
your zmq socket (look at dns.c). Which avoid hacking the "core"
directly. That allow you to register some external callback on the
socket event.

Beautiful! I saw that socket type but I didn't quite figure out how to
use it - that would make things much nicer.

On a related note, can I safely use the data field in the ape_socket
struct for arbitrary socket information (in this case a pointer to the
zmq socket itself) or is there a better way to do that?

Andrew




--
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/

Reply via email to