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
Solved

Using Winsock To Tell When Disconnected from Net

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
This video teaches viewers about errors in exception handling.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

860 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