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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:03:19+00:00 2026-06-02T17:03:19+00:00

I dont understand whats happening. If I create a socket to anywhere else other

  • 0

I dont understand whats happening. If I create a socket to anywhere else other than localhost (either “localhost”, “127.0.0.1” or the external ip of the machine) it works fine.
If I create a socket to an address without something listening in that port i would get a 10060 (timeout) but not a 10061 which makes sense. Why is it that I am getting connection refused when going to localhost.
I tried disabling the firewall just in case it was messing things up, but that is not it

I am doing all the WSA initialize stuff before this.

    _socketToServer = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    if(_socketToServer == -1){
    return false;
    }

   p_int = (int*)malloc(sizeof(int));
   *p_int = 1;
   if( (setsockopt(_socketToServer, SOL_SOCKET, SO_REUSEADDR, 
       (char*)p_int, sizeof(int)) == -1 )||
       (setsockopt(_socketToServer, SOL_SOCKET, SO_KEEPALIVE, (char*)p_int,
               sizeof(int)) == -1 ) ){
        free(p_int);
        return false;
   }
   free(p_int);


   struct sockaddr_in my_addr;

   my_addr.sin_family = AF_INET ;
   my_addr.sin_port = htons(_serverPort);

   memset(&(my_addr.sin_zero), 0, 8);
   my_addr.sin_addr.s_addr = inet_addr(_serverIP);


   if( connect( _socketToServer, (struct sockaddr*)&my_addr, sizeof(my_addr)) 
        == SOCKET_ERROR ){
    DWORD error = GetLastError(); //here is where I get the 10061
    return false;
}

Any ideas?

  • 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-02T17:03:23+00:00Added an answer on June 2, 2026 at 5:03 pm

    You are not guaranteed to get a WSAETIMEDOUT error when connecting to a non-listening port on another machine. Any number of different errors can occur. However, a WSAETIMEDOUT error typically only occurs if the socket cannot reach the target machine on the network before connect() times out. If it can reach the target machine, a WSAECONNREFUSED error means the target machine is acknowledging the connect() request and is replying back saying the requested port is not able to accept the connection at that time because either it is not listening or its backlog is full (there is no way to differentiate which). So, when you are connecting to the localhost, you will pretty much always get a WSAECONNREFUSED error when connecting to a non-listening port because you are connecting to the same machine and there is no delay in determining the port’s listening status. It has nothing to do with firewalls or anti-malwares. This is just normal behavior.

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

Sidebar

Related Questions

I don't quite understand whats happening here a=[1,2,3,4] b=[5,6,7,8] a[len(a):] = b seems to
This is a very noobish mistake, but I dont know whats happening here. There
I don't understand what's happening here. If someone could explain, I would appreciate it.
I just don't understand what's happening, I haven't change anything to the site for
I dont understand what would be the problem with the following code. It needs
I am having trouble removing a column which is indexed. I dont really understand
I don't understand what happens here : use PAR { file => 'foo.par', fallback
I don't understand what Dusan Jovanovic means when he refers to host_element in his
I don't understand what lifting is. Should I first understand monads before understanding what
I don't understand what I'm doing wrong here: public void Draw(GameTime gameTime) // in

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.