src/share/classes/java/net/AbstractPlainSocketImpl.java

Print this page




 351                 // If we have a ref. to the Socket, then sets the flags
 352                 // created, bound & connected to true.
 353                 // This is normally done in Socket.connect() but some
 354                 // subclasses of Socket may call impl.connect() directly!
 355                 if (socket != null) {
 356                     socket.setBound();
 357                     socket.setConnected();
 358                 }
 359             } finally {
 360                 releaseFD();
 361             }
 362         } catch (IOException e) {
 363             close();
 364             throw e;
 365         }
 366     }
 367 
 368     /**
 369      * Binds the socket to the specified address of the specified local port.
 370      * @param address the address
 371      * @param port the port
 372      */
 373     protected synchronized void bind(InetAddress address, int lport)
 374         throws IOException
 375     {
 376        synchronized (fdLock) {
 377             if (!closePending && (socket == null || !socket.isBound())) {
 378                 NetHooks.beforeTcpBind(fd, address, lport);
 379             }
 380         }
 381         socketBind(address, lport);
 382         if (socket != null)
 383             socket.setBound();
 384         if (serverSocket != null)
 385             serverSocket.setBound();
 386     }
 387 
 388     /**
 389      * Listens, for a specified amount of time, for connections.
 390      * @param count the amount of time to listen for connections
 391      */




 351                 // If we have a ref. to the Socket, then sets the flags
 352                 // created, bound & connected to true.
 353                 // This is normally done in Socket.connect() but some
 354                 // subclasses of Socket may call impl.connect() directly!
 355                 if (socket != null) {
 356                     socket.setBound();
 357                     socket.setConnected();
 358                 }
 359             } finally {
 360                 releaseFD();
 361             }
 362         } catch (IOException e) {
 363             close();
 364             throw e;
 365         }
 366     }
 367 
 368     /**
 369      * Binds the socket to the specified address of the specified local port.
 370      * @param address the address
 371      * @param lport the port
 372      */
 373     protected synchronized void bind(InetAddress address, int lport)
 374         throws IOException
 375     {
 376        synchronized (fdLock) {
 377             if (!closePending && (socket == null || !socket.isBound())) {
 378                 NetHooks.beforeTcpBind(fd, address, lport);
 379             }
 380         }
 381         socketBind(address, lport);
 382         if (socket != null)
 383             socket.setBound();
 384         if (serverSocket != null)
 385             serverSocket.setBound();
 386     }
 387 
 388     /**
 389      * Listens, for a specified amount of time, for connections.
 390      * @param count the amount of time to listen for connections
 391      */