How many is the maximum number of sockets in java under windows? How can I change it?
The theoretical maximum is 65535, since a 16-bit number is used to store the port number in the TCP/IP packet, and port 0 is not usable. The practical limit will be lower since a number of ports will already be in use by the system.
This is largely dependent on the max number of file descriptors (handles in Windows) the OS is configured for. Each open file or socket uses one file descriptor. In Solaris, for example, 65536 is the default for max fd's. Chances are, there are additional files using the pool of FD's, therefore limiting the upper limit of sockets unless the OS is tuned to increase the number of FD's
In Windows NT/2000/XP (Probably Vista & 7) there should be an entry "FILES=" in \Windows\System32\config.nt (Possibly also a registry setting?) that should give you the max number of file handles.
Here is a more in depth discussion of the limits in Windows:
http://blogs.technet.com/markrussinovich/archive/2009/09/29/3283844.aspx
It depends on the configuration of your Windows installation. I don't think that Windows has a process specific limit on the number of TCP connections, but there is a system wide configuration in the registry. You can find an article here, in which the registry keys are described.