[Nice] When can we send()?
Youness Alaoui
youness.alaoui at collabora.co.uk
Mon Sep 27 13:27:15 PDT 2010
That's an excellent question..
returning -1 means that an error happened, in the case of non-reliable, it might
mean that something went really wrong, and it shouldn't happen... (although I
think it might, but I'm not sure in which use case a socket_send on a UDP socket
would return -1)
However, in reliable mode, although -1 means an error occured, it just means
either one of these two errors : NOT_CONNECTED or WOULD_BLOCK.. the
NOT_CONNECTED errors just means that you're not connected, so you should wait
for the writable signal, and the WOULD_BLOCK also means that it couldn't send
anything, in which case, you also need to wait the writable signal...
In other words, yes, if it returns -1, you should just wait for the signal and
continue, as if nothing happened...
I hope this makes it clearer.. and yes, I should document that properly.
Thanks,
Youness.
On 09/27/2010 03:02 PM, Tony Di Croce wrote:
> Ok, I know what to do when nice_agent_send() return less than the number
> of bytes I've requested... But I'd like clarification on 1 thing.... If
> it returns -1, should I keep trying, or does that indicate something
> unrecoverable has occurred?
>
> td
>
>
> On Wed, Sep 1, 2010 at 12:19 PM, Youness Alaoui
> <youness.alaoui at collabora.co.uk <mailto:youness.alaoui at collabora.co.uk>>
> wrote:
>
> Yeah, it's like any normal reliable socket, you only write stuff to
> do when it
> becomes 'writable'. Read the docs correctly, it will initially send
> you the
> writable signal when it's ready.. and after that, whenever you call
> send (), if
> it doesn't return '-1' OR a value less than what you asked it to
> write, then it
> will NOT send a new signal.. so you have to keep track of that.. as
> soon as you
> receive a reponse of -1 (or < len) then you must wait for the new
> writable signal.
>
> Youness.
>
> On 09/01/2010 12:04 PM, Tony Di Croce wrote:
> > Ah... I'm guessing I should be looking for
> > "reliable-transport-writable"... I'll try that...
> >
> > td
> >
> > On Wed, Sep 1, 2010 at 9:01 AM, Tony Di Croce <dicroce at gmail.com
> <mailto:dicroce at gmail.com>
> > <mailto:dicroce at gmail.com <mailto:dicroce at gmail.com>>> wrote:
> >
> > I have found that unless I sleep for 3 seconds after whichever
> agent
> > is that last to reach NICE_COMPONENT_STATE_READY, my calls to
> > nice_agent_send() will fail (return -1, btw, this is with a
> reliable
> > agent, haven't tried it with unreliable)...
> >
> > Is there some other event I should listening for or is this normal
> > behaviour?
> >
> > td
> >
> >
> >
> >
> > _______________________________________________
> > Nice mailing list
> > Nice at lists.freedesktop.org <mailto:Nice at lists.freedesktop.org>
> > http://lists.freedesktop.org/mailman/listinfo/nice
>
>
>
> _______________________________________________
> Nice mailing list
> Nice at lists.freedesktop.org <mailto:Nice at lists.freedesktop.org>
> http://lists.freedesktop.org/mailman/listinfo/nice
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/nice/attachments/20100927/bd533a3e/attachment.pgp>
More information about the Nice
mailing list