Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CAsyncSocket - Blocking vs. Non-blocking

50 views
Skip to first unread message

David

unread,
Dec 3, 2003, 2:51:33 PM12/3/03
to
In reading the MSDN library, there are a lot of statements
like "A socket can be in 'blocking mode' or 'nonblocking
mode'."

Specifically, in dealing with the function Send(...) what
happens if the receiving end isn't ready to accept? In
some of the articles, it looks like it blocks, in others
it looks like it ought to return with a WSAEWOULDBLOCK
error. The description of WSAEWOULDBLOCK says "The socket
is marked as non-blocking and the requested operation
would block."

So how do I "mark a socket as non-blocking"?

I thought that was the default. It looks like my code is
occaisionally blocking on the Send function. I thought it
should return WSAEWOULDBLOCK, and move on.

Any assistance would be appreciated.

Scott McPhillips [MVP]

unread,
Dec 3, 2003, 9:00:47 PM12/3/03
to
David wrote:

CAsyncSocket creates a nonblocking socket. Send does not block. Note
that Send does not directly return WSAEWOULDBLOCK. It returns
SOCKET_ERROR and then you have to call GetLastError to see the
WSAEWOULDBLOCK code.

The blocking condition does not necessarily occur when the receiving end
isn't ready. Winsock buffers outgoing messages at the sending end. It
will continue accepting Send calls until its buffers are full. If that
happens then it will indicate WSAEWOULDBLOCK.

--
Scott McPhillips [VC++ MVP]

number 94

unread,
Dec 3, 2003, 9:34:32 PM12/3/03
to
Is CAsyncSocket::IOCtl what you are after?

"David" <da...@blackdeck.com> wrote in message
news:01e801c3b9d6$da9f2ab0$a401...@phx.gbl...

0 new messages