简体   繁体   中英

java.net.ConnectException: the system lacked sufficient buffer space or because a queue was full

I am trying to check the connectivity by pinging various IPs by the following code.

ipAdd = InetAddress.getByName(ipAddress);
            boolean isConnected = ipAdd.isReachable(3000);

But I get this error.

java.net.ConnectException: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full

The reson being there are around 1000 threads doing this process simultaneously. I have thought about keeping these IPs in a queue. But for that I want to know the maximum number of Threads I can use. Is there any way to find out the buffer space so that I can figure out the number of threads to be triggered simultaneously that will run the above code. I would appreciate any other work around/solution apart from the queueing method.

I guess this exception occurs because you have exceeded the limit of ports that can be used by your application.
do you close your connections?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM