Re: Question about howto do proper timeout checking on connections

From: Arkady Frenkel (arkadyf_at_hotmailxdotx.com)
Date: 07/04/04


Date: Sun, 4 Jul 2004 09:18:43 +0300

Interesting that due to
http://support.microsoft.com/default.aspx?scid=kb;en-us;131623 sync socket
doesn't support timeouts and even return error on setsockopt.
Just to ckeck if it happen if you remoove overlap flag and call
setsockopt ?
Arkady

"Onemangang" <theonemangang@hotmail.com> wrote in message
news:OFvRq%23uXEHA.3944@tk2msftngp13.phx.gbl...
> Hi Alun.
>
> Thank you for your answer, that is a very good
> suggestion. I will make the list a linked list. This way
> "cpu expensive" deletion and insertion isnt needed.
> Only thing needed to push a socket to the end of the
> list is to exchange a few pointers, wich is fast to do.
>
> But, when doing this while running multiple threads,
> a lock will be needed to protect the list from corruption.
> Then each time you read or write and need to push the
> socket to the end of the list, this lock must be used.
>
> This sounds "expensive" in terms of locking that needs
> to be done when there is heavy traffic.
> Would this not cut down the performance ?
>
> - Onemangang
>
>
> "Alun Jones [MSFT]" <alunj@online.microsoft.com> skrev i en meddelelse
> news:eMQhdmrXEHA.2940@TK2MSFTNGP09.phx.gbl...
> > "Onemangang" <theonemangang@hotmail.com> wrote in message
> > news:uL2ZR2cXEHA.1656@TK2MSFTNGP09.phx.gbl...
> > > Setsockopt returns zero, indicating that the so_rcvtimeo was
> > > set sucessfully. I used a timeout of 2500 ms to test this.
> >
> > Implementing your own timeouts is a better way of doing this, because
you
> > can include the timeout processing in your regular worker thread pools.
I
> > don't know if so_rcvtimeo is supported for all non-blocking sockets, but
> the
> > documentation for setsockopt does state that so_rcvtimeo is supported
for
> > recv(). You are using WSARecv().
> >
> > On the topic of the way you're timing out, why not simply build a sorted
> > structure (a list or something), on the basis of how soon the socket
will
> > time-out? Each time data is received or sent on a socket, just pump it
to
> > the end of the list, and when it's time to check for timeouts, you just
> > remove those sockets at the front that are timed out, and don't search
if
> > the front socket isn't ready to be timed out. And you use the timeout
> value
> > of the first socket as being the next time to wait.
> >
> > Alun.
> > ~~~~
> >
> >
>
>



Relevant Pages

  • Re: GNAT.Sockets: Timeval_Duration is in milliseconds?
    ... So if you are using Windows, Microsoft's decision to screw things up ... I suppose we have to report this as a bug in GNAT though it would be ... Personally I've never used timeouts -- I've used selectand waited ... Sets with only one socket seems to be overcomplication, ...
    (comp.lang.ada)
  • Re: WriteFile()
    ... You will get just the same with some timeouts. ... socket because the peer socket has stopped receiving is not an error; ... not behaving "properly", because it could return, successfully, without ... writing as much as requested. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Question about howto do proper timeout checking on connections
    ... But, when doing this while running multiple threads, ... a lock will be needed to protect the list from corruption. ... socket to the end of the list, ... > Implementing your own timeouts is a better way of doing this, ...
    (microsoft.public.win32.programmer.networks)
  • Weird behavior with either reading or write()ing !?
    ... an event is pending on a given socket. ... I am receiving a lot of read timeouts. ... another GET request on a keepalive connection). ... To test the possibility of perhaps KQueue not notifying me of data waiting, ...
    (freebsd-hackers)
  • Weird behavior with either reading or write()ing !?
    ... an event is pending on a given socket. ... I am receiving a lot of read timeouts. ... another GET request on a keepalive connection). ... To test the possibility of perhaps KQueue not notifying me of data waiting, ...
    (freebsd-net)