[SDL] How to know when SDLNet_TCP_Recv has no more data available, or how to specify timeout for it?
Alvin
alvinbeach at gmail.com
Mon Oct 8 04:24:09 PDT 2007
On 08/10/2007, DARKGuy . <dark.guy.2008 at gmail.com> wrote:
> Yeah, is there a way to specify a timeout for SDLNet_TCP_Recv, or how to
> know when there's no more data, so SDLNet_TCP_Recv doesn't stay waiting
> for data to arrive? I'm thinking in using SDL threads, but I'm still not
> sure how do I apply them in my case...
>
> I've also tried to search in google but I haven't found any info about
> applying a timeout either by SDL_Net or by threads...
>
> Any help is greatly appreciated! :D
>
> - DARKGuy
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).
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.
Alvin
More information about the SDL
mailing list