Hi,

I am trying to write a server program that accepts a large number of
socket connection. However, when the number of sockets goes over about
250, the accept call either blocks, or throws an
InvalidArgumentException.

I did wonder if this is related to the maximum number of open file
descriptors allowed ? However, the problem occurs on NT and AIX as well
as Linux.

My server code can be summarized as follows:

import java.util.*;
import java.net.*;
import java.io.*;

public class Serv
{
    ServerSocket ss;

    public void go() throws IOException
    {
      ss = new ServerSocket(9876);
      int i =0;
      Vector v = new Vector();
      while (true)
      {
       System.out.println(">");
       Socket cs = ss.accept();
       System.out.println("<");
       v.addElement(cs);
       System.out.println("Accepted " + (i++));
      }
    }

    public static void main(String[] args) throws IOException
    {
       Serv s = new Serv();
       s.go();
    }
}

Can anyone suggest what I need to do to address this ? Thanks.

Rob

Reply via email to