Re: CSocket

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Michael K. O'Neill wrote:
...CSocket calls the underlying winsock send() function, which returns
immediately since the socket is non-blocking.  If all data was sent
successfully, CSocket::Send() returns, whereas if all data was not yet sent,
then CSocket::Send() pumps messages (i.e., it calls AfxPumpMessages()) and
then tries the winsock send() function again, until all data is sent
successfully or an error on the socket is detected.

So I don't fully understand what you meant when you said that the "app will
stop responding to the user while CSocket is blocked inside a Send or
Receive call..." As far as I can see, the app will continue to respond to
the user since the underlying socket is completely non-blocking and
CSocket::Send() (or Receive()) pumps messages.

Hi Michael,
Thanks. First, it's been a long time since I used CSocket. Once was enough! I later changed that app to CAsyncSocket and I've been using CAsyncSocket ever since.


I'm looking at the source code for the version of CSocket in VC6, and it doesn't agree with your description. For example, there is no call to AfxPumpMessages() in this version. It doesn't pump application messages, only messages sent to the invisible socket window. So perhaps your comments are correct for the more modern versions.

--
Scott McPhillips [VC++ MVP]

.



Relevant Pages

  • Re: CSocket
    ... >> ...CSocket calls the underlying winsock sendfunction, ... >> immediately since the socket is non-blocking. ... >> successfully or an error on the socket is detected. ...
    (microsoft.public.vc.mfc)
  • Re: Bug with Socket
    ... replace the following functions in MSocketSupport and CSocket. ... are you ignoring any specific socket errors? ... Dim strTemp As String ... Winsock API function ...
    (microsoft.public.vb.bugs)
  • Re: CAsyncSocket in a DLL, frequent crashes on close in DetachHandle
    ... doesn't have a message pump, so my socket was disfunctional - receiving ... my next step was to create and use the CSocket from a separate UI ... that the 'listener' therad was killed before I tried ...
    (microsoft.public.vc.mfc)
  • Re: CSocket
    ... CSocket simulates a blocking socket, ... Your app will stop responding to the ... CSocket is not actually a blocking socket; ...
    (microsoft.public.vc.mfc)
  • Re: [6.x] problem with AIO, non-blocking sockets on freebSD and IE7 on windows.
    ... Yes, Blame Microsoft, but we are breaking the TCP spec, not them. ... A TCP socket isn't the same thing as a named pape or FIFO. ... Using non-blocking I/O does not mean one can suddenly shortcut the FINWAIT-1 and FINWAIT-2 states before going into TIME_WAIT, nor the 2 * MSL timeout before the TCP control block is allowed to go away. ... Otherwise, you might end up sending a RST to a dup'ed packet like a stray ACK, which seems to be almost exactly the problem at hand. ...
    (freebsd-net)