< prev index next >

test/java/nio/channels/Selector/ByteServer.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -26,10 +26,11 @@
  * and write bytes.
  * @author kladko
  */
 
 import java.net.Socket;
+import java.net.SocketException;
 import java.net.ServerSocket;
 import java.net.SocketAddress;
 import java.net.InetSocketAddress;
 import java.io.IOException;
 import java.io.Closeable;

@@ -41,10 +42,14 @@
 
     ByteServer() throws IOException {
         this.ss = new ServerSocket(0);
     }
 
+    void setTimeout(int timeout) throws SocketException {
+        ss.setSoTimeout(timeout);
+    }
+
     SocketAddress address() {
         return new InetSocketAddress(ss.getInetAddress(), ss.getLocalPort());
     }
 
     void acceptConnection() throws IOException {
< prev index next >