Java examples for Network:Socket
Creating a Non-Blocking Server Socket
import java.awt.Graphics; import java.io.IOException; import java.net.InetSocketAddress; import java.nio.channels.ServerSocketChannel; public class Main { public void m() { // Create a non-blocking server socket and check for connections try {//from w ww. j a v a 2 s.c o m // Create a non-blocking server socket channel on port 80 ServerSocketChannel ssChannel = ServerSocketChannel.open(); ssChannel.configureBlocking(false); int port = 80; ssChannel.socket().bind(new InetSocketAddress(port)); } catch (IOException e) { } } }