[SDL] [Framework] Event-based Networking

Glocke cgloeckner at freenet.de
Tue Mar 19 01:50:52 PDT 2013


Nathaniel J Fries wrote:
> Anyway, the cleverness I talked of involves using non-blocking I/O on sockets (via SDLNet_SocketReady() IIRC) and SDLNet_CheckSockets() to drive a single network thread. You could optimize this some with a thread-per-processor and doing some load balancing, but ultimately it would still fall well short of what is provided by I/O Completion Ports, epoll, kqueue, or whatever other operating systems provide, and which boost.asio cleverly wraps.


Actual I am using non-blocking TCP sockets by using SocketReady and CheckSockets. But I tried to reduce massivly thread-usage in the first place to enable easier debugging. But you're right: using some more threads would enable improved performance on multi-processor computers. But what's a suitable number of threads (server-sided): one for accepting clients, and one per client? Or is it too much? From the point of multi-processor computer it might be simple: one thread per client. But does this have a negative effect on single-processor devices? I don't know :? 


Jared Maddox wrote:
> In conclusion: Glocke, you should remove the kill function from your
> code, and generify it sufficiently that it works natively with both
> SDL 1.2 and SDL 2.0. Further, I suggest redesigning the thread api to
> resemble the one provided by C++11, so that your code can be quickly
> and easily used as a replacement for the C++11 library on platforms
> that support SDL, but don't have C++11 thread support implemented.


Okay, more C++11 ^^ 


Jared Maddox wrote:
> I especially recommend the SDL 2.0 portion. SDL 1.2 is now antiquated
> by virtue of it's API, and there's no changing that. If you want your
> library to be used, then you need to target SDL 2.0


I focused on SDL 1.2 after some experiments with SDL 2.0. Unfortunally I had huge problems with linking (absolutly my fault), so I decided to stay at SDL 1.2 at the first place and adapt my code in future to by SDL 2.0 ready.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130319/ee83e467/attachment-0009.htm>


More information about the SDL mailing list