×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
Jeff,
Each socket has a read buffer and a write buffer. When you do a send()
or write() to a socket, it will be placed in the buffer if there's
enough space, and your program will not need to wait for the data to
actually traverse the network.
In blocking mode, if there is not enough space in the write buffer, the
program will stop and wait until space is available, and the send/write
call will only return control to your program after space has been made
available in the buffer.
In non-blocking mode, if there's space in the buffer, it will work just
like blocking mode, but if there isn't space in the buffer it will
return only as many bytes as could be successfully placed in the buffer
(i.e. the return value from send() or write() will be smaller than the
mount you asked to write) and errno will be set to EWOULDBLOCK to let
you know why the data couldn't be written.
If you get EWOULDBLOCK, you can use the select() API to wait until
there's space again by waiting until the buffer is writeable.
I'm not familiar with your application, so I can't tell you if this
would have an "adverse affect", but I would recommend using non-blocking
all of the time, and using select() when necessary to wait for stuff to
be ready. This makes your programs MUCH more robust in my experience.
On 8/20/2015 10:57 AM, Jeff Young wrote:
I have read the tutorial the Scott Klement has regarding using Non-blocked
sockets to test for timeouts on a recv function.
I have a client socket program that connects to a server, sends data and
then waits for a reply on the same socket that it sent the data on.
If I set the socket to Non-Blocked at the start of the program, will it
have any adverse effect on my send of data or will it only effect the
receive?
TIA
Jeff Young
Sr. Programmer Analyst
As an Amazon Associate we earn from qualifying purchases.