/**
  * Creates a new socket that is not bound to any local address/port and is not connected to any
  * remote address/port. The stream parameter will be ignored since PlainSocketImpl always is a
  * stream socket. Datagram sockets are handled by PlainDatagramSocketImpl.
  *
  * @param stream <code>true</code> for stream sockets, <code>false</code> for datagram sockets
  */
 protected synchronized void create(boolean stream) throws IOException {
   channel = new SocketChannelImpl(false);
   VMChannel vmchannel = channel.getVMChannel();
   vmchannel.initSocket(stream);
   channel.configureBlocking(true);
   impl.getState().setChannelFD(vmchannel.getState());
 }
  /**
   * Closes the socket. This will cause any InputStream or OutputStream objects for this Socket to
   * be closed as well.
   *
   * <p>Note that if the SO_LINGER option is set on this socket, then the operation could block.
   *
   * @throws IOException if an error occurs
   */
  protected void close() throws IOException {
    if (impl.getState().isValid()) impl.close();

    address = null;
    port = -1;
  }