< prev index next >

## src/com/sun/javatest/agent/SocketConnection.java

Print this page

     167                     if (i == -1) {
     168                         break;
     169                     }
     170                 } catch (IOException ignore) {
     171                     break;
     172                 }
     173             }
     174         } finally {
     175             timer.cancel(e);
     176
     177             synchronized (this) {
     178                 waitThread = null;
     179             }
     180             if (Thread.interrupted()) {
     181                 throw new InterruptedException();
     182             }
     183         }
     184     }
     185
     186     private static String getHostName(InetAddress addr) {
     187         String s = (String) (addressCache.get(addr));
     188         if (s == null) {
     189             s = addr.getHostName();
     190             addressCache.put(addr, s);
     191         }
     192         return s;
     193     }
     194
     195     /**
     196      * Creates a ServerSocket instance in the environment where reading
     197      * of system properties is allowed.
     198      *
     199      * @param port - port to bind
     200      * @return new created ServerSocket
     201      * @throws java.io.IOException - if ServerSocket is not created
     202      */
     203     public static ServerSocket createServerSocket(int port) throws IOException {
     204         return createServerSocket(port, 50);
     205     }
     206
     207     /**
     221         if (sm != null && sm instanceof JavaTestSecurityManager) {
     222             jtSm = (JavaTestSecurityManager) sm;
     223             prev = jtSm.setAllowPropertiesAccess(true);
     224         }
     225         try {
     226             ServerSocket serverSocket = new ServerSocket(port, backlog);
     227             return serverSocket;
     228         } finally {
     229             if (jtSm != null) {
     230                 jtSm.setAllowPropertiesAccess(prev);
     231             }
     232         }
     233     }
     234     private final Socket socket;
     235     protected final InputStream socketInput;
     236     private final OutputStream socketOutput;
     237     private String name;
     238     private boolean closed;
     239     private Thread waitThread;
     240     private static Timer timer = new Timer();
     241     private static Hashtable addressCache = new Hashtable();
     242 }
     167                     if (i == -1) {
     168                         break;
     169                     }
     170                 } catch (IOException ignore) {
     171                     break;
     172                 }
     173             }
     174         } finally {
     175             timer.cancel(e);
     176
     177             synchronized (this) {
     178                 waitThread = null;
     179             }
     180             if (Thread.interrupted()) {
     181                 throw new InterruptedException();
     182             }
     183         }
     184     }
     185
     186     private static String getHostName(InetAddress addr) {
     187         String s = addressCache.get(addr);
     188         if (s == null) {
     189             s = addr.getHostName();
     190             addressCache.put(addr, s);
     191         }
     192         return s;
     193     }
     194
     195     /**
     196      * Creates a ServerSocket instance in the environment where reading
     197      * of system properties is allowed.
     198      *
     199      * @param port - port to bind
     200      * @return new created ServerSocket
     201      * @throws java.io.IOException - if ServerSocket is not created
     202      */
     203     public static ServerSocket createServerSocket(int port) throws IOException {
     204         return createServerSocket(port, 50);
     205     }
     206
     207     /**
     221         if (sm != null && sm instanceof JavaTestSecurityManager) {
     222             jtSm = (JavaTestSecurityManager) sm;
     223             prev = jtSm.setAllowPropertiesAccess(true);
     224         }
     225         try {
     226             ServerSocket serverSocket = new ServerSocket(port, backlog);
     227             return serverSocket;
     228         } finally {
     229             if (jtSm != null) {
     230                 jtSm.setAllowPropertiesAccess(prev);
     231             }
     232         }
     233     }
     234     private final Socket socket;
     235     protected final InputStream socketInput;
     236     private final OutputStream socketOutput;
     237     private String name;
     238     private boolean closed;
     239     private Thread waitThread;
     240     private static Timer timer = new Timer();
     241     private static Hashtable<InetAddress, String> addressCache = new Hashtable<>();
     242 }

< prev index next >