[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[Libevent-users] Do paired buffer events work?



I've been trying to use them for a while now, without much success.

I seem to be able to put data into "my" side of the pair, and it appears
on the "remote" side -- but no callbacks are called on the remote end.

    Log("WebSocket %p received %u bytes",this,(unsigned
int)TheMessage->payload_len);
    if
(bufferevent_write(MyBufferEvent,TheMessage->payload,(size_t)TheMessage->payload_len)!=0)
    {
        /* throw ... */
    }
    else
    {
        bufferevent_flush(MyBufferEvent,EV_WRITE|EV_READ,BEV_NORMAL);

        Log("MyBufferEvent has output size
%d",(int)evbuffer_get_length(bufferevent_get_output(MyBufferEvent)));
        Log("RemoteBufferEvent %p has input size %d",(struct
bufferevent*)RemoteBufferEvent,(int)evbuffer_get_length(bufferevent_get_input(RemoteBufferEvent)));

        Log("RemoteBufferEvent has reading enabled:
%s",(bufferevent_get_enabled(RemoteBufferEvent) & EV_READ) ? "yes"
: "no");

This actually gives me the expected output, such as

[2015-02-19 08:08:54] WebSocket 0x7f8f080008c0 received 4 bytes
[2015-02-19 08:08:54] MyBufferEvent has output size 0
[2015-02-19 08:08:54] RemoteBufferEvent 0x7f8f08001370 has input size 4
[2015-02-19 08:08:54] RemoteBufferEvent has reading enabled: yes

but that's it -- the callback on the remote end simply isn't called.

I can send more data to the websocket thing and it's just added to the
output buffer of the "remote" end of the pair like it should, except that
it's never used since the callbacks are never invoked.

The same applies when I run flush with a BEV_FINISHED to signal an "EOF"
-- it's not happening on the remote end.

I'm just going to try calling those callbacks myself, probably with some
testing to detect when those callbacks start working so I know to update
the code then; not currently expecting too many problems with that. The
question is whether I'm still doing something wrong, somewhere, or whether
those callbacks are only meant for "real" sockets?

I was using "2.1.4-alpha" up until a couple of hours ago; updated to
"2.1.5-beta" and ran the thing again, but it didn't seem to change
anything

***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.