Sending will only block if the buffers have gotten too full. So rather than sending non-blocking, just select with a 0 time-out. If select fails, then report that failure and don't send (instead of sending non-blocking and reporting that the attempt failed). Though I wonder if that could run into problems if the amount of data you are trying to send is in large chunks. I suspect the select mechanism means that instead of blocking the socket would either only send part of the data or would fail with something like EMSGSIZE (depending on the type of socket).
The usual way this type of thing is done is to have multiple objects that queue up read and write requests and then one select loop that reads/writes for any sockets that are ready for their queued requests. Having your server "lock up" waiting for a reply certainly sounds "not very elegant" to me.
- tye
In reply to Re: nonblocking socket back to blocking (select)
by tye
in thread nonblocking socket back to blocking
by netrom
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |