my cgi application in c++ uses another application written in c++ to talk to mainframe using TCP/IP call.
When i am increasing the number of request from cgi to that application , i am getting WSAECONNREFUSED error code.
I know WSAECONNREFUSED means No connection could be made because the target machine actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host - i.e. one with no server application running.

Can any body help me resolving this issue.How can I change my application to increase the number of request that it can handle.
Please help!!!
Who is Participating?
jhanceConnect With a Mentor Commented:
This is a SERVER problem and cannot be fixed on your application.  All you really can do is work around it.

What you should do, if this is caused by a server being too busy, is to setup a retry scheme and queue and have your application retry the connection so that it can eventually make a connection.

If you have any control of the server code, you might look there and see WHY it's refusing your connection.  I could be that the server is overloaded, the listening socket has too small a backlog setting.
Providing you know how many concurrent connections your mainfram app can handle, you can create a connection -pool on the client side (with as many connections as possible). When requests are made, they try to grab a connection from the pool, and wait if no connection is available. It will allow your client to handle more request, but at a lower pace.
Another thought...

Is there any way to continue to use ONE connection to the server instead of continuing to open new sockets?
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

msrijnaAuthor Commented:
server is not refusing any connection.My application which is running on the server and which is used for making tcp/ip connection to mainframe is refusing connection to cgi call.
cgi calls don't get connected to.  I think you are confused.

You said, and I quote:

"talk to mainframe using TCP/IP call."

Mainframe = SERVER

SERVER is the problem as it is REFUSING your connection request.

Fix the problem on the server or do something DIFFERENT on your CLIENT to eliminate the problem.

You cannot FORCE the server to accept your incoming connection and the WSAECONNREFUSED error message is what happens when the SERVER refuses to talk to your client.

Got it?
msrijnaAuthor Commented:
Oh I am sorry I confused you guys.
Here is the architecture :

CGI SERVER ----> Monitor Server-----> Mainframe

Now CGI server makes a cgi call to monitor which is a application running on a different  server and cgi call is made on a particular port and monitor application( written in c++)  sends the same request to Mainframe.
Now as and when I am increasing the number of CGI calls to Monitor , monitor is refusing connection to CGI calls  on that port.
It is returning the error code of WSAECONNREFUSED.
I would like to tell you that i am using WINSOCk 1.1 version in the monitor applicaiton for listening to CGI calls which might be the bottleeneck
when you invoke listen() passing the server socket, you also specify the size of the backlog (ie maximum number of pending connections between accept() calls). Try increasing the backlog size. It might not be the best sollution if you're anticipating a constant high load, but it will take care of peak-loads.
msrijnaAuthor Commented:
I am using winsock 1.1 and in case of winsock 1.1 the maximum number of backlog could be 5 .
When i am increaisng the number of requests, backlog is exceeding 5 and hense resfusing connection.
Have you considered multi-threading your server app. That way, one thread can exclusively accept connections and spawn threads to do the work wih the connected sockets.
If you are using WINSOCK 1.1, that implies to me that you have Windows 95 or Windows 98 on your monitor "server".  Right?  If so, neither of these platforms is suitable for this type of application.

Get a different platform to run your monitor application that is not limited to WINSOCK 1.1 and it's 5 connection backlog.

If your hands are tied here, you'll need to re-architect.  Win95/98 are intentionally limited (i.e. crippled) to prevent you from using a backlog of more than 5.

If this is really a server platform (i.e. NT4 Server, W2K Server) then use the WINSOCK 2 interface and get rid of this WINSOCK 1.1 backlog limitation.
msrijnaAuthor Commented:
I am using windows 2000 and winsock1.1.
Is there any other way otherthan upgrading winsock2.0
I fail to see how multithreaded can help here.  It's a SERVER issue!!!

I'm still totally confused about your arrangement and am frustrated by your lack of information being provided.

Windows 2000???  What Windows 2000, Pro or Server or Adv. Server?  Where is Windows 2000 running, on your client, on the "monitor server", on the mainframe, all of the above what?

It's really hard to give useful and helpful advice with so little to go on.

What also are you using WINSOCK 1.1 on W2K?  Any version of W2K has WINSOCK 2 by default! But again, the CLIENT is not the issue.  Again to re-iterate, the SERVER (in your case the monitor server) is where the problem in your situation is coming up.  You CANNOT force the server to accept more incoming connections from your client than the SERVER permits.

To again review your options:

1) FIX the SERVER to accept more than 5 incoming connections.

2) FIX the ARCHITECTURE so that greater load on the system does not require more socket connections between the client and the server.

Frankly, I think you'd do well to explore #2.  If you have any hopes in the future of scaling this to a larger system it will very quickly break down.  Gosh, you're already hitting limits with 5 connections.  What's going to happen with 500 or 5000 or even more??

A socket connection is a fairly expensive thing in terms of resources and performance.  In general it is NOT a good architecture to have a 1:1 relationship between your users and your socket connections to the server.

Why can't you design this to have the client open ONE SINGLE socket connection to the monitor server and have ALL the communications go through that single socket?  I think you'll find that the overhead is greatly reduced and the performance is greatly improved.
msrijnaAuthor Commented:
I am so sorry for not provoding the enough details .I will try to put whole architecture in following lines:

CGI Server
 configuration: windows 2000 advansed server
web server : IIS 5.0
CGI application written in c++

Monitor server :
 configuration: windows 2000 advansed server
Monitor applicaiton written in c++ MFC which receives request from CGI application using TCP/IP.This monotor application runs continuosly on monitor server and receives request from CGI appication runing on different CGI server.Monitor application receives all the calls from CGI application on a particular port specified.

CGI server---CGI call---> Monitor application running on monitor server  receives the CGI call using TCP/IP and cals mainframe.

Now problem is in the frist step where CGI application is making call to Monitor application running on monitor server.When I increase the number of calls to monior application, Monitor application continues to accpet calls from CGI application but at particular limit it refuses connection to CGI application and returns error code of WSAECONNREFUSED.
Monitor application uses winsock 1.1 for listening to the specified port where CGI application sends all the calls.

So I dont think that there is any problemm in the server as server is not listening to CGI application but a application( Monitor application which is running on the Server ) is listening to all teh calls of CGI applicaiton on pre specified port.
Please let me know if I have explained the situation .
Please help me .

Dear msrijna

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept


comment(s) as an answer.

Force accepted

** Mindphaser - Community Support Moderator **
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.