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 7927495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:19:50+00:00 2026-06-03T19:19:50+00:00

I want to reduce the allowed timeOut time that socket:connect will take to look

  • 0

I want to reduce the allowed timeOut time that socket:connect will take to look up an IP/Port to connect to? On some network routers like Netgear that use IP 10.0.0.x only takes less than a second to timeout.

Note: “select” comes later

host = gethostbyname("xxx");//invalid IP, 

memcpy(&(sin.sin_addr), host->h_addr, host->h_length);
sin.sin_family = host->h_addrtype;
sin.sin_port = htons(4000);

s = socket(AF_INET, SOCK_STREAM, 0);
hConnect = connect(s, (struct sockaddr*)&sin, sizeof(sin));//sits here for 2 minutes before moving on to the next line of code

bConn = 0;// no connect
if (hConnect == 0) {
    bConn = 1;// connect made
}

thx

  • 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-06-03T19:19:52+00:00Added an answer on June 3, 2026 at 7:19 pm

    Set the socket to non-blocking prior to calling connect(), and then do a select() or poll() on it to find out any events going on on it.

    Note: Using this setup you’ll be getting a non-zero return from connect() and errno is set to EINPROGRESS in the case connect() returns without having connected but still is trying to do.

    Please see the ERRORS section of connect()‘s man page for more on this.

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

Sidebar

Related Questions

I will build a system where I want to reduce single-point-of-failures, and I need
I have a long, lazy sequence that I want to reduce and test lazily.
I have a set of thumbnails that I want to reduce to 40% when
I want to reduce the size of the Rating bar, I got some style
I want to reduce compile time on a large project. Our primary compiler is
Suppose that I have a property containing c:\workdir\project\wonder\subproj\..\..\common and I want to reduce/simplify it
Assuming that I have a Windows Forms textbox and want to reduce the maximum
I want to reduce polling in my application solution (many apps, 1 database, some
i want to reduce the number of times i hit the data base to
I have a scenario where I want to reduce the margin of a Button

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.