Ejemplo n.º 1
0
  // Look up an older packet for responses
  // Return true if the packet is unique; false if we have seen it before
  private boolean rememberPacket(GnutellaPacket pkt) {
    GnutellaConnection gc = (GnutellaConnection) packetTable.get(pkt.getGUID());
    if (gc != null) return false;

    if (DEBUG) System.err.println("**** REMEMBERING: " + pkt + " from " + pkt.getConnection());

    packetTable.put(pkt.getGUID(), pkt.getConnection());
    return true;
  }
Ejemplo n.º 2
0
  // Send the packet to everyone but the originator
  private void forwardPacketToAll(GnutellaPacket pkt) {
    if ((pkt.ttl == 0) || (--pkt.ttl == 0)) {
      if (VERBOSE) System.err.println("-- Dropping packet, TTL expired: " + pkt);
    }
    pkt.hops++;

    if (DEBUG) System.err.println("**** FORWARDING: " + pkt + " to all but " + pkt.getConnection());

    // System.err.println("FORWARDING "+pkt);
    gs.sendToAllButOne(pkt, pkt.getConnection());
  }