The returned object will not declare any public methods that are not declared in the {@link java.net.ServerSocket} class.
20372038203920402041204220432044204520462047
server.socket().bind( new InetSocketAddress(InetAddress.getLocalHost(), 0), 5); Socket client = new Socket(InetAddress.getLocalHost(), server.socket() .getLocalPort()); client.setTcpNoDelay(false); Socket worker = server.socket().accept(); SocketChannel workerChannel = worker.getChannel(); OutputStream out = client.getOutputStream(); out.write(request); out.close();
26902691269226932694269526962697269826992700
*/ public void test_socketChannel_read_ByteBufferII_remoteClosed() throws Exception { // regression 1 for HARMONY-549 ServerSocketChannel ssc = ServerSocketChannel.open(); ssc.socket().bind(localAddr2); SocketChannel sc = SocketChannel.open(); sc.connect(localAddr2); ssc.accept().close(); ByteBuffer[] buf = { ByteBuffer.allocate(10) }; assertEquals(-1, sc.read(buf, 0, 1));
27062707270827092710271127122713271427152716
* @tests SocketChannel#write(ByteBuffer[], int, int) */ public void test_socketChannel_write_ByteBufferII() throws Exception { // regression 2 for HARMONY-549 ServerSocketChannel ssc = ServerSocketChannel.open(); ssc.socket().bind(localAddr2); SocketChannel sc = SocketChannel.open(); sc.connect(localAddr2); SocketChannel sock = ssc.accept(); ByteBuffer[] buf = { ByteBuffer.allocate(10), null }; try {
27292730273127322733273427352736273727382739
* @tests SocketChannel#read(ByteBuffer[], int, int) with a null ByteBuffer */ public void test_socketChannel_read_ByteBufferII_bufNULL() throws Exception { // regression 3 for HARMONY-549 ServerSocketChannel ssc = ServerSocketChannel.open(); ssc.socket().bind(localAddr2); SocketChannel sc = SocketChannel.open(); sc.connect(localAddr2); ssc.accept(); ByteBuffer[] buf = new ByteBuffer[2]; buf[0] = ByteBuffer.allocate(1);
27522753275427552756275727582759276027612762
* @tests SocketChannel#write(ByteBuffer) after close */ public void test_socketChannel_write_close() throws Exception { // regression 4 for HARMONY-549 ServerSocketChannel ssc = ServerSocketChannel.open(); ssc.socket().bind(localAddr2); SocketChannel sc = SocketChannel.open(); sc.connect(localAddr2); SocketChannel sock = ssc.accept(); ByteBuffer buf = null; ssc.close();
27782779278027812782278327842785278627872788
// regression 5 for HARMONY-549 final String testStr = "Hello World"; ByteBuffer readBuf = ByteBuffer.allocate(11); ByteBuffer buf = ByteBuffer.wrap(testStr.getBytes()); ServerSocketChannel ssc = ServerSocketChannel.open(); ssc.socket().bind(localAddr2); SocketChannel sc = SocketChannel.open(); sc.connect(localAddr2); buf.position(2); ssc.accept().write(buf); assertEquals(9, sc.read(readBuf));
9293949596979899100101102
{ doListen = true; // allocate an unbound server socket channel ServerSocketChannel serverChannel = ServerSocketChannel.open(); // Get the associated ServerSocket to bind it with ServerSocket serverSocket = serverChannel.socket(); // create a new Selector for use below Selector selector = Selector.open(); // set the port the server channel will listen to serverSocket.bind (new InetSocketAddress (bind,tcpListenPort)); // set non-blocking mode for the listening socket
56835684568556865687568856895690569156925693
public void test_Constructor_LReadableByteChannel() throws IOException { InetSocketAddress localAddr = new InetSocketAddress("127.0.0.1", Support_PortManager.getNextPort()); ServerSocketChannel ssc = ServerSocketChannel.open(); ssc.socket().bind(localAddr); SocketChannel sc = SocketChannel.open(); sc.connect(localAddr); sc.configureBlocking(false); assertFalse(sc.isBlocking());
358359360361362363364365366367368
try { ssc = ServerSocketChannel.open(); ssc.configureBlocking( false ); ssc.socket().bind( req.address, req.backlog ); ssc.register( selector, SelectionKey.OP_ACCEPT, req ); channels.put( req.address, ssc ); } catch( IOException e )
135136137138139140141142143144145
* @param localEp InetAddress whose port to listen on. */ public void listen(InetAddress localEp) throws IOException { ServerSocketChannel serverChannel = ServerSocketChannel.open(); final ServerSocket ss = serverChannel.socket(); ss.setReuseAddress(true); ss.bind(new InetSocketAddress(localEp, DatabaseDescriptor.getStoragePort())); new Thread(new Runnable() {