private function pingSocket() {
    // Create a package.
    $type = "\x08";
    $code = "\x00";
    $checksum = "\x00\x00";
    $identifier = "\x00\x00";
    $seq_number = "\x00\x00";
    $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;

    // Calculate the checksum.
    $checksum = $this->calculateChecksum($package);

    // Finalize the package.
    $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;

    // Create a socket, connect to server, then read socket and calculate.
    if ($socket = socket_create(AF_INET, SOCK_RAW, 1)) {
      socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array(
        'sec' => 10,
        'usec' => 0,
      ));
      // Prevent errors from being printed when host is unreachable.
      @socket_connect($socket, $this->host, null);
      $start = microtime(true);
      // Send the package.
      @socket_send($socket, $package, strlen($package), 0);
      if (socket_read($socket, 255) !== false) {
        $latency = microtime(true) - $start;
        $latency = round($latency * 1000);
      }
      else {
        $latency = false;
      }
    }
    else {
      $latency = false;
    }
    // Close the socket.
    socket_close($socket);
    return $latency;
  }