Solved

ServerSocket

Posted on 2001-07-19
9
315 Views
Last Modified: 2012-06-27
Hiya,

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("127.0.0.1",portNumber);
statement..

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

Any Idea's "?

best regards,
tom
0
Comment
Question by:tomschuring1
9 Comments
 
LVL 92

Expert Comment

by:objects
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?
0
 
LVL 92

Expert Comment

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

Expert Comment

by:objects
ID: 6301095
0
 

Expert Comment

by:jerrycao
ID: 6301626
it is better to paste ur source code here...
if u do not mind.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 2

Expert Comment

by:userquin
ID: 6301638
Hi:

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.

Bye.

J.
0
 
LVL 1

Expert Comment

by:swapsthegreat
ID: 6302232
i think the queue limit is 25 connections
0
 

Author Comment

by:tomschuring1
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 ?
0
 
LVL 92

Accepted Solution

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

Expert Comment

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

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now