Re: CAsyncSocket blocks

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Mikael Setterberg (setterberg_at_hotmail.com)
Date: 05/25/04


Date: 25 May 2004 06:10:20 -0700

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



Relevant Pages

  • Re: Context of error messages with respect to BSD sockets
    ... under what circumstances will send or recv block? ... A 'connection mode' socket usually has an in-kernel send and ... receive buffer associated with it. ... this signifies that the connection has closed ...
    (comp.unix.programmer)
  • RE: Does Socket.Shutdown or Socket.Close Block and when?
    ... keeps trying to send the data in the send buffers of the socket until TCP ... in the send buffer has been sent or the timeout has elapsed. ... > connection is still up to each client). ... > heartbeat within say 10 seconds then the server will proceed to shutdown the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Socket BeginSend and disconnections
    ... What determines the length of time between this remote user yanking his ... It does depend somewhat on how the connection is broken and where. ... In theory, you should be able to queue as many sends as you need, especially if you've set the socket buffer itself to 0 ). ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Does Socket.Shutdown or Socket.Close Block and when?
    ... receive a heartbeat message every 5 seconds on each socket (to make sure the ... connection is still up to each client). ... heartbeat within say 10 seconds then the server will proceed to shutdown the ... the send buffer is empty or becomes empty before the elapsed timeout. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Context of error messages with respect to BSD sockets
    ... A 'connection mode' socket (eg TCP) usually has an in-kernel send and ... receive buffer associated with it. ... this signifies that the connection has closed ...
    (comp.unix.programmer)