Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using Winsock To Tell When Disconnected from Net

Posted on 1998-12-04
2
Medium Priority
?
177 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 80 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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

886 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