Re: CAsyncSocket blocks
From: Paul G. Tobey [eMVP] (ptobey_no_spam_at_instrument_no_spam.com)
Date: 05/25/04
- Next message: Mike Hughes: "Re: Retrieving text from CEdit box as char *?"
- Previous message: P.J. Plauger: "Re: Embedded VC++ woes."
- In reply to: Mikael Setterberg: "Re: CAsyncSocket blocks"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 25 May 2004 09:34:59 -0700
It's not blocking because of network I/O, but because of the OS situation.
If it were me, I'd fail the call entirely and return WSAEWOULDBLOCK in that
case, but maybe they don't do that. You can call select() in WinSock to
check for writability, but I'm not sure, if you are filling the buffers
completely, if that will work or not. By the way, there's no detectable
benefit that I've ever found to using those MFC socket things. WinSock
works virtually identically and has far fewer strange little things that
don't work. We *never* use MFC for sockets...
Paul T.
"Mikael Setterberg" <setterberg@hotmail.com> wrote in message
news:e289800e.0405250510.5490b8a2@posting.google.com...
> Thanks for your reply!
> If that is the case (which it sure looks like), why does Microsoft
> make a distiction between blocking and non-blocking sockets?
> CAsyncSocket is supposed to be non-blocking. I have not found a way of
> reading the send buffer status either so I cannot know if the call is
> going to block or not. And trying to change the TCP/IP send timeout is
> not supported by WinSock..
>
> Thanks,
>
> Mikael
>
> > I think that your guess about what it should do is wrong. When there's
no
> > more room to buffer packets, the send should *block*, waiting for enough
> > room in the buffer to store the bytes which you requested to have sent.
If
> > no space in the buffer is cleared in a sufficiently long time (the other
end
> > of the connection is no longer reachable, as far as TCP/IP can tell,
> > basically), the send will fail entirely and the socket will drop into an
> > error state where you must reconnect to reestablish communication.
> >
> > Paul T.
> >
>
>
> > > Hi,
> > > I'm developing an application where a Windows CE 4.1 client connects
> > > via Wireless Ethernet to a server on an XP machine. When the
> > > connection has been established, the client continously streams
> > > (~200KByte/s) data to the server. I use eVC and the CAsyncSocket class
> > > and is has worked out fine.
> > > However, the speed of the WL connection is not constant and depends on
> > > the distance to the nearest access point. The problem (as far as I
> > > understand) arises when the speed has dropped to a level where the
> > > TCP/IP connection cannot keep up anymore and the data in the send
> > > buffer starts to grow until the buffer is full. Suddenly the
> > > CAsyncSocket::Send function stops returning and instead gets stuck. I
> > > would expect it to return a number of bytes sent lower than originally
> > > requested in the call? I use a 200KByte send buffer at the moment.
> > > I cannot figure out why the socket behaves like this. Has anyone else
> > > experienced this?
> > >
> > > Thanks,
> > >
> > > Mikael
- Next message: Mike Hughes: "Re: Retrieving text from CEdit box as char *?"
- Previous message: P.J. Plauger: "Re: Embedded VC++ woes."
- In reply to: Mikael Setterberg: "Re: CAsyncSocket blocks"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|