Re: [Dclib-devel] non blocking patch
Brought to you by:
davisking
|
From: Davis K. <dav...@us...> - 2009-05-18 00:03:55
|
I have been testing out this patch for a while (on windows and linux) and trying to think if there are any funny corner cases. I also spent a lot of time a few years ago trying to work something like this into the connection object and ended up giving up but I forgot why until just now. Anyway, I found a problem related to sending data via send(). The problem is that send() will block, even if select() says it won't, if you give it a buffer larger than a certain value (the value depends on your platform and isn't at all portable). Linux allows you to set the MSG_DONTWAIT flag which fixes the issue but MSG_DONTWAIT isn't a POSIX thing and so isn't portable to other platforms. See http://www.opengroup.org/onlinepubs/009695399/functions/send.html for example. I think the only safe way to get this to work is to create the socket in non-blocking mode to begin with. Then we don't have to worry about functions blocking when hidden buffer size limits are hit. So I think that would mean making a new object that explicitly represented a non-blocking socket. I'm not in any dire need for non-blocking sockets so I probably won't be implementing this any time soon. You might also want to check out the asio library ( http://think-async.com/Asio/). It has a whole lot of support for varous kinds of networking modes. It is also, in all probability, the networking library that will eventually make it into C++ standard library. So it might be worth learning just for that reason :) Cheers, Davis On Fri, Apr 17, 2009 at 7:35 PM, miguelg50 <mig...@ve...> wrote: > Davis, > > Attached is the patch for the non-blocking socket changes I've made. I hope > it is useful. > > Miguel |