Solved

Using Winsock To Tell When Disconnected from Net

Posted on 1998-12-04
2
170 Views
Last Modified: 2013-11-13
Is there a command(s) which can tell me if I'm still connected to the internet or disconnected? I don't want to check the "state" method in a repeating loop after a connect call and wait for an error to occur to tell if its been disconnected. What I want to know is if Im already connected to the net and am trasnfering something via the winsock control and then all of a sudden i get disconnected is there a function to let me know when this disconnection happens?
0
Comment
Question by:ljaques
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
kacklehorn earned 20 total points
ID: 1448151
No..you need a timer with this code. There is no other way unless theres an API I don't know about, but since the winsock control is just a wrapper for wsock32.dll, I doubt it.

Private Sub Timer1_Timer()
  Select Case svrsock.State
Case 0
    Me.Caption = "Closed"
Case 1
    Me.Caption = "Open"
Case 2
    Me.Caption = "Listening"
Case 3
    Me.Caption = "Connection pending"
Case 4
    Me.Caption = "Resolving host"
Case 5
    Me.Caption = "Host resolved"
Case 6
    Me.Caption = "Connecting"
Case 7
    Me.Caption = "Connected"
Case 8
    Me.Caption = "Peer is closing the connection"
Case 9
    Me.Caption = "Error"
End Select
End Sub

0
 

Author Comment

by:ljaques
ID: 1448152
Thanks a lot
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
This article will show, step by step, how to integrate R code into a R Sweave document
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question