tomschuring1
asked on
ServerSocket
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.s ocketConne ct(Native Method)
at java.net.PlainSocketImpl.d oConnect(P lainSocket Impl.java: 312)
at java.net.PlainSocketImpl.c onnectToAd dress(Plai nSocketImp l.java:125 )
at java.net.PlainSocketImpl.c onnect(Pla inSocketIm pl.java:11 2)
at java.net.Socket.<init>(Soc ket.java:2 73)
at java.net.Socket.<init>(Soc ket.java:1 00)
at mytestpackage.testConnecti onThread.r un(testCon nectionThr ead.java:3 8)
from the
Socket aSocket = new Socket("127.0.0.1",portNum ber);
statement..
I'm running JDK1.3 on NT4.0 SP6 but hope it is not an OS problem..
Any Idea's "?
best regards,
tom
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:
at java.net.PlainSocketImpl.s
at java.net.PlainSocketImpl.d
at java.net.PlainSocketImpl.c
at java.net.PlainSocketImpl.c
at java.net.Socket.<init>(Soc
at java.net.Socket.<init>(Soc
at mytestpackage.testConnecti
from the
Socket aSocket = new Socket("127.0.0.1",portNum
statement..
I'm running JDK1.3 on NT4.0 SP6 but hope it is not an OS problem..
Any Idea's "?
best regards,
tom
It could also possibly be running out of threads??
How many connections are we talking about?
How many connections are we talking about?
it is better to paste ur source code here...
if u do not mind.
if u do not mind.
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.
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.
i think the queue limit is 25 connections
ASKER
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 ?
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 ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry I couldn't give a more definitive answer.
Thanks for the points :)
Thanks for the points :)
WHat was the error (if any) on the server side?