[SDL] How to know when SDLNet_TCP_Recv has no more data available, or how to specify timeout for it?
DARKGuy .
dark.guy.2008 at gmail.com
Mon Oct 8 10:56:13 PDT 2007
What about threads? :( I wouldn't mind to make some SDL_Threads...
On 10/8/07, Gregory Smith <wolfy at treellama.org> wrote:
>
> On Mon, 8 Oct 2007, Alvin wrote:
>
> > What I have done is send the number of bytes before hand. The receiver
> then
> > knows how many bytes to expect. For example, the sender transmits a
> single
> > integer (the number of bytes for the payload) which is expected by the
> > receiver. The receiver gets the integer and uses that value to receive
> > exactly those number of bytes for the second transmission (e.g. the
> payload).
>
> This only works, of course, for protocols you invent yourself.
>
> > Another solution could be to have the receiver read one byte at a time.
> The
> > sender would then send a control byte (of some kind) to indicate the end
> of
> > the transmission.
>
> I have to imagine that's really inefficient.
>
> We use SDL_Net currently, but we go behind its back and make the sockets
> non-blocking in an ugly, platform specific way. I'm surprised no one here
> has responded with the stock "Use threads" response--but non-blocking
> reads are far easier and not much more inefficient than setting up a whole
> thread system.
>
> The answer to the original question is, you can't, really :(
>
> Gregory
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20071008/79775734/attachment-0001.html
More information about the SDL
mailing list