dcsimg
Getting problem during using sockets in threads
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Yasir_Khan
Posted On:   Tuesday, June 11, 2002 02:24 AM

I have written a simple server using java.net.ServerSocket and java.net.Socket, I have also written a client that bombard the requests to server. Server and Client both are running on different machines. In client i create 100 threads and in each thread i create a seprate socket object that connects to my server. Now the problem is, In 50 to 60 threads the sockets are created successfully, and after that I get following exception for remaining threads. 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)   More>>

I have written a simple server using java.net.ServerSocket and java.net.Socket, I have also written a client that bombard the requests to server. Server and Client both are running on different machines. In client i create 100 threads and in each thread i create a seprate socket object that connects to my server. Now the problem is, In 50 to 60 threads the sockets are created successfully, and after that I get following exception for remaining threads.


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. (Socket.java:273)

at java.net.Socket. (Socket.java:100)




Anyone please tell me, how can i run my 100 client threads successfully. Thanx.


Regards,


YK

   <<Less

Re: Getting problem during using sockets in threads

Posted By:   Martin_Kernland  
Posted On:   Wednesday, June 12, 2002 12:16 AM

Hi

It looks like the problem is not the threads (try to make 100 threads that do something else than opening sockets...).

The problem seems to be opening more than (my guess) 64 sockets. What operating system do you use? I once had the problem to open more than 256 sockets on solaris. But there are system commands to change this (needs root priviledge).

So: check if it is a socket or a thread problem. If it is a thread problem, check your operating system manual for limitations :-).

-Martin
About | Sitemap | Contact