/**
   * Closes this datagram socket.
   *
   * <p>Any thread currently blocked in {@link #receive} upon this socket will throw a {@link
   * SocketException} and this datagram socket will wait for it to return.
   *
   * @see DatagramSocket#close()
   */
  @Override
  public void close() {
    super.close();

    if (inReceiveSyncRoot == null) return;

    synchronized (inReceiveSyncRoot) {
      boolean interrupted = false;

      while (inReceive > 0)
        try {
          inReceiveSyncRoot.wait();
        } catch (InterruptedException iex) {
          interrupted = true;
        }
      if (interrupted) Thread.currentThread().interrupt();
    }
  }