Пример #1
0
  private void transmitDatagram(MessagePacket p, boolean tryToAppendACKInfo) {
    // append SACK chunk if we can
    if (tryToAppendACKInfo && appendSACKData(p, false)) {
      _lastSACKTransmitTime = System.currentTimeMillis();
      _unacknowledgedPackets = 0;
    }

    // fill in outgoing datagram packet
    p.setWindowSize(_receiver.getCurrentWindowSize());
    p.setValidation(_validation);
    p.writeToDatagramPacket(_outgoingPacket);

    _outgoingPacket.setAddress(_remoteAddress);
    _outgoingPacket.setPort(_remotePort);

    // send packet over the socket
    try {
      _dgSocket.send(_outgoingPacket);
    } catch (IOException e) {
      e.printStackTrace();
    }

    // update last transmission time
    _lastTransmitTime = System.currentTimeMillis();

    Thread.yield();
  }