[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 08:10:12 PDT 2007


First of all thanks for answering guys :)

for Alvin:
That would work if I was working on the server program, but I'm just making
a chat client for the Battle.net protocol, similar to TopazChat but
multiplatform thanks to wxWidgets, since WINE has small issues with
emulating TopazChat... mainly slowdowns and such... since I can't edit the
server itself (duh :P) I'm stuck to make something generic.

for Brian:
Yup! I tried that yesterday when Walk from #sdl suggested it to me, it kinda
worked as expected, so we can say the issue is a bit resolved...

However, could any of you, if possible, make some example client program
that uses the SocketSets ? I've seen server examples in a wiki... dunno if
it was GPWiki or SDL wiki because I'm typing this at work and I can't recall
correctly, but I never saw any client example using SocketSets... I'd be
really glad if any of you could make one of those, since I learn better by
code rather than theory... xD... it'd also help others :).

Thanks for answering :D

- DARKGuy

On 10/8/07, Alvin <alvinbeach at gmail.com> wrote:
>
> 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
>
>
> _______________________________________________
> 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/8cfe15f9/attachment.html 


More information about the SDL mailing list