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

Winsock Timeout

78 views
Skip to first unread message

Tony Garcia

unread,
Sep 28, 1998, 3:00:00 AM9/28/98
to
What's the best way to implement a connect or read timeout in my winsock
wrapper class? I've noticed that online help says the BSD socket option for
timeouts is not available.. so obviously I have to do my own.

Any ideas? I know in the KB there is an article on using SetTimer and
KillTimer for CSocket, but SetTimer and KillTimer are members of CWnd.

Also, does anyone know if ::connect and ::recv block internally until
data is ready or a connection is made?

Any help is appreciated,

Tony

Jason Teagle

unread,
Sep 29, 1998, 3:00:00 AM9/29/98
to

Tony Garcia wrote in message ...

The API versions of ::SetTimer() and ::KillTimer() can be used without a
window. If you use CSocket, the functions will block by default (although
you may be able to switch this off). CAsyncSocket (which is perfectly
usable) does not.

If you call Connect(), it will eventually timeout (without the need for
timers) and the OnConnect() method will fire with an error code. The timeout
isn't that long.


Does this help?

_ _
o o Jason Teagle
<
v jte...@solartron.com

Please ONLY respond via e-mail if you want to catch my attention - I don't
necessarily look at the newsgroups all the time.


Patrice

unread,
Sep 29, 1998, 3:00:00 AM9/29/98
to
i use csocket in a thread and a watch dog in a separate thread witch issue a
CancelBlockingCall on the csocket if it does nothing since a parametered
time.
This work well when the connection is established. But during the Connect,
it seems that the socket is waiting based on a IP timeout in the registry.
This timeout is 45s on NT3.51 and NT4.0. I tryed to modify this value (i
want 120 s) but i never succeed.
anyone know ?

Eduardo Calixto

unread,
Sep 29, 1998, 3:00:00 AM9/29/98
to
Hello Tony,

If your socket works in blocking mode you can implement a timeout control
using the ::select function. This is the right way.
I have some samples here if you need

Calixto
(Brazil)

ma...@axess.com

unread,
Oct 5, 1998, 3:00:00 AM10/5/98
to
BSD socket options ARE valid!!! Use setsockopt().

MS

On Mon, 28 Sep 1998 18:06:00 -0400, "Tony Garcia" <ton...@isint.net>
wrote:

alex_yt...@yahoo.com

unread,
Oct 11, 1998, 3:00:00 AM10/11/98
to
I've implemented a nonblocking socket for connect, and then use select to
timeout the attempt. But you are host if the IP is bogus(I just posted a
question asking for help on this one).

The nonblocking socket works if the IP points to a machine that is up, and the
port is set to listen() but no one is doing accept().


In article <OBjTW5$69GA...@uppssnewspub04.moswest.msn.net>,


"Eduardo Calixto" <ecal...@ibm.net> wrote:
> Hello Tony,
>
> If your socket works in blocking mode you can implement a timeout control
> using the ::select function. This is the right way.
> I have some samples here if you need
>
> Calixto
> (Brazil)
>
> Tony Garcia wrote in message ...

> > What's the best way to implement a connect or read timeout in my
> winsock
> >wrapper class? I've noticed that online help says the BSD socket option
> for
> >timeouts is not available.. so obviously I have to do my own.
> >
> > Any ideas? I know in the KB there is an article on using SetTimer and
> >KillTimer for CSocket, but SetTimer and KillTimer are members of CWnd.
> >
> > Also, does anyone know if ::connect and ::recv block internally until
> >data is ready or a connection is made?
> >
> >Any help is appreciated,
> >
> >Tony
> >
> >
>
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

0 new messages