> I'm writing a multi-threaded Java program that continuously opens a socket
> connection to a server (SMTP server). However, if I have too many threads
> going at once, I get a "BindException: Address in use." It seems like there
> is a limit to the number of sockets I can create? (Is that true?) And also,
> the Java VM is probably not closing the other sockets fast enough.
> Has anyone come across this before?
> Thanks for any help!
> -Chung
You may bind exactly 1 socket to a specific address/port. If you
attempt to bind another socket to the same address/port you will
get the error you mentioned. The number of sockets that can be
opened is equal to the maximum number of file descriptors
available to the process, under Solaris the soft limit is 64
by default. This can be changed via setrlimit() in C.
--
Staff Software Engineer
3Com Carrier Systems Group, R&D
"UNIX _IS_ user friendly, its just picky about who its friends are."