Solved

WSAECONNREFUSED problem

Posted on 2008-06-09
6
1,127 Views
Last Modified: 2013-12-14
I am using Winsock inside two programs. In one program, the code to startup the connection is working perfectly. This program is a simly command line where all it does is perform the connection, and send and recieve a little data, all this works fine.

I have another program. It's a windows API application, alot going on. I implement that exact same code, and when the connect method gets call, I'm not getting the socket back but an error. WSAECONNREFUSED. This is the error you get when the service is not at that address on that port. But it is.

I even know that the connection is somewhat happening. I am the developer of the server program as well. I can see the connection get made on the server.

Why might this be happening in the windows program, but no the command line?

Thanks!
Matthew
0
Comment
Question by:mattososky
  • 3
  • 3
6 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 21745503
>> I even know that the connection is somewhat happening.

What do you mean by somewhat ?


>> WSAECONNREFUSED

As you said, this means that either there's no service listening at the targeted port. Buut it could also be caused by a firewall for example.
0
 

Author Comment

by:mattososky
ID: 21745777
The server is registering the client connection, it's just the stream seems to close before and data is sent or recieved.

The service is definately there and accessable. As I already said, another program using the same code and variables is hitting the service normally
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 500 total points
ID: 21745907
>> The server is registering the client connection

So, the accept call returns successfully ?


>> As I already said, another program using the same code and variables is hitting the service normally

Apparently there is some difference between the two tests you performed ... I'm just trying to find it :) Try to go over the complete test, and note any differences, however small, between the two.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Closing Comment

by:mattososky
ID: 31465467
Yes, I rearranged the code to be an exact duplicate, even though it was logicall the same, and now it works. I'm truely stumped as to why. It is logically 100%, the different being a few variable being global instead of local to the functions. But the scope is handled correcty as well is implementation. Also serveral calls on those vairiables leading up to the point of failure worked fine. I'm not sure why, but it's working....
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 21746181
>> the different being a few variable being global instead of local to the functions.

Is the application multi-threaded ?


>> I'm not sure why, but it's working....

That's good then :)
0
 

Author Comment

by:mattososky
ID: 21746907
The client protion where I saw the problem is single threaded.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

827 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