Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6040085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:27:48+00:00 2026-05-23T06:27:48+00:00

I’m working on a legacy VB6 app. The app uses the RAS API to

  • 0

I’m working on a legacy VB6 app. The app uses the RAS API to establish a modem connection, then uses a winsock control to connect to an IP address & port.

I’m now adding a “failover” feature to this app where if it can’t connect to a server, it tries to connect to the next one in the list.

Let’s say I have two servers, server app A and server app B. (During my tests I’ve swapped these around to verify that both servers are accessible and there are no routing / firewall issues.)

If I stop server app A, then something quite strange happens when the app tries to connect to server app A and then server app B:

mySocket.close
mySocket.Connect serverA, portA
  • mySocket.state = 6 sckConnecting
  • socket connect event is called
  • mySocket.state = 7 sckConnected
  • mySocket.state = 8 sckClosing

(which seems slightly odd: I’m not sure why it appears to connect for a few moments.)

The socket remains in sckClosing state. After a few hundred milliseconds I move on to try to connect to server B:

mySocket.close
  • mySocket.state = 0 sckClosed

.

mySocket.Connect serverB, portB
  • mySocket.state = 6 sckConnecting
  • socket error event is called with error 10060 (WSAETIMEDOUT)
  • mySocket.state = 9 sckError

At this point if I start server app A, do a RAShangup and a RASdial, and try to connect to server A, all works OK.

It’s as if the sequence

socket.connect ip, port
socket.close
socket.connect newIP, newPort

doesn’t work properly unless a RAShangup and RASdial is inserted. Instead it fails with WSAETIMEDOUT.

Is there anything I need to do between a close and connect call?

Note: I’ve tried making sure that the close call has really closed, but this doesn’t help:

Private Sub closeSocket(ByRef w As Winsock)
  w.Close
  Do While (w.State <> sckClosed)
    DoEvents
  Loop
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:27:48+00:00Added an answer on May 23, 2026 at 6:27 am

    After looking again at the project, it turns out that a previous developer set the LocalPort property of the winsock control to a nonzero value. This was preventing the reuse of the winsock control.

    Setting this to zero causes a random local port to be selected, which allows the control to be reused.

    Lesson learned: when dealing with VB6 I need to look at the property settings as well as the source code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I am writing an app with both english and french support. The app requests
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.