if (closed) throw new SocketException ("Socket is closed");
if (isClosed()) throw new SocketException("socket is closed");
  public void bind (SocketAddress bindpoint) throws IOException  {    if (closed)      throw new SocketException ("Socket is closed");    // XXX: JDK 1.4.1 API documentation says that if bindpoint is null the    // socket will be bound to an ephemeral port and a valid local address.    if (bindpoint == null)      bindpoint = new InetSocketAddress (InetAddress.ANY_IF, 0);        if ( !(bindpoint instanceof InetSocketAddress))      throw new IllegalArgumentException ();    InetSocketAddress tmp = (InetSocketAddress) bindpoint;        // bind to address/port    try      {        getImpl().bind (tmp.getAddress(), tmp.getPort());      }    catch (IOException exception)      {        close ();        throw exception;      }    catch (RuntimeException exception)      {        close ();        throw exception;      }    catch (Error error)      {        close ();        throw error;      }  }