Posted on 2001-07-19
Medium Priority
Last Modified: 2012-06-27

I created the 'standard' echo-server using the ServerSocket. Each new connection is handled in its own thread. it all works fine with a few clients.

I then wrote a small client that creates heaps of threads each trying to connect to the echo-server.. this gives me unpredictable errors.. If i startup n-clients (in n-threads) anywhere from 0-n threads can't connect to the echo-server and come back with a :

java.net.ConnectException: Connection refused: no further information
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:312)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:125)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:112)
        at java.net.Socket.<init>(Socket.java:273)
        at java.net.Socket.<init>(Socket.java:100)
        at mytestpackage.testConnectionThread.run(testConnectionThread.java:38)

from the
Socket aSocket = new Socket("",portNumber);

I'm running JDK1.3 on NT4.0 SP6 but hope it is not an OS problem..

Any Idea's "?

best regards,
Question by:tomschuring1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 92

Expert Comment

ID: 6301084
I think there's a os limit to the number of open sockets.
WHat was the error (if any) on the server side?
LVL 92

Expert Comment

ID: 6301093
It could also possibly be running out of threads??
How many connections are we talking about?
LVL 92

Expert Comment

ID: 6301095
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more


Expert Comment

ID: 6301626
it is better to paste ur source code here...
if u do not mind.

Expert Comment

ID: 6301638

In server side you create a ServerSocket. If you use ServerSocket(int port) constructor it creates a queue for incoming requests with a lenght of 50. If you exceed 50 (queue is full) connections it throws a ConnectionException exception (refused, what you catch).

You can prefix queue length using ServerSocket(int port, int backlog) constructor. I do not know if there is a OS restriction for this.



Expert Comment

ID: 6302232
i think the queue limit is 25 connections

Author Comment

ID: 6306713
the minimum number of connections that I can get it to happen with is 100

I did do do a mServerSocket = new ServerSocket(port,1000);

just to make sure it is not the QueueSize that blows me up.

There is no error on the server side at all.

I have just moved the server to a windowsNT Server (I am running workstation) and it started to accept all connections. mmmmm seems to work properly now. what do i do with the points ? Howabaout I'll give them to someone who can explain why it doesn't work on workstation ?
LVL 92

Accepted Solution

objects earned 400 total points
ID: 6306750
At a guess it has a smaller limit on open sockets.
LVL 92

Expert Comment

ID: 6307190
Sorry I couldn't give a more definitive answer.
Thanks for the points :)

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month14 days, 2 hours left to enroll

801 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