Non blocking socket method?

Is there a method like:

Socket s = serversocket.accept();

thatdoes not block a program?

Or a method for checking if there are any connections waiting to be accepted like:

if(serversocket.connectionsWaiting()){

socket = serversocket.accept();

}

Thanks, Rufus

[400 byte] By [Rufus0a] at [2007-9-30 2:23:03]
# 1
use function setSoTimeout() and then make a loop over the accept() try, as long as you want to get a connection!nocomm
nocomma at 2007-7-16 13:32:25 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 2
Orjava.nio.channels.ServerSocketChannel
tschodta at 2007-7-16 13:32:25 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 3
Couldn't you just use a separate Thread to monitor the ServerSocket? That way, you won't have to have your program "freeze" before accepting connections.
RageMatrix36a at 2007-7-16 13:32:25 > top of Java-index,Archived Forums,New To Java Technology Archive...