Solved

Using Winsock To Tell When Disconnected from Net

Posted on 1998-12-04
2
165 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
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem to skip loop 6 49
countHi challenge 25 84
wordlen challenge 3 47
VB6 - Compare and highlight cell not the same 3 33
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

758 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now