Called implicitly before a packet is sent.
767914
def post_build(self, p, pay):
    
    p += pay
    if self.auxdlen != 0:
      print("NOTICE: A properly formatted and complaint V3 Group Record should have an Auxiliary Data length of zero (0).")
      print("        Subsequent Group Records are lost!")
    return p
830191
async function beforeEachHook(done) {
    browser.__autoStart = browser.__prom = browser.__rejectSerial = browser.__resolveSerial = null;
    done && done();
}
1089775
protected final void beforeDelivery(MessageEndpoint endpoint) {

        if (TRACE.isEntryEnabled()) {
            final String methodName = "beforeDelivery";
            SibTr.entry(this, TRACE, methodName, endpoint);
            SibTr.exit(this, TRACE, methodName);
        }

    }
1139463
def handleDat(self, pkt):
        """"""
        log.info("Handling DAT packet - block %d" % pkt.blocknumber)
        log.debug("Expecting block %s", self.context.next_block)
        if pkt.blocknumber == self.context.next_block:
            log.debug("Good, received block %d in sequence", pkt.blocknumber)

            self.sendACK()
            self.context.next_block += 1

            log.debug("Writing %d bytes to output file", len(pkt.data))
            self.context.fileobj.write(pkt.data)
            self.context.metrics.bytes += len(pkt.data)
            # Check for end-of-file, any less than full data packet.
            if len(pkt.data) < self.context.getBlocksize():
                log.info("End of file detected")
                return None

        elif pkt.blocknumber < self.context.next_block:
            if pkt.blocknumber == 0:
                log.warning("There is no block zero!")
                self.sendError(TftpErrors.IllegalTftpOp)
                raise TftpException("There is no block zero!")
            log.warning("Dropping duplicate block %d" % pkt.blocknumber)
            self.context.metrics.add_dup(pkt)
            log.debug("ACKing block %d again, just in case", pkt.blocknumber)
            self.sendACK(pkt.blocknumber)

        else:
            # FIXME: should we be more tolerant and just discard instead?
            msg = "Whoa! Received future block %d but expected %d" \
                % (pkt.blocknumber, self.context.next_block)
            log.error(msg)
            raise TftpException(msg)

        # Default is to ack
        return TftpStateExpectDAT(self.context)
266346
public void prewrite(byte[] b,int offset, int length)
    {
        ensureReserve(length);
        System.arraycopy(b,offset,_buf,_start-length,length);
        _start-=length;
    }
177991
def send(self, packet, interfaces=None):
        """"""
        interfaces = interfaces or self.interfaces  # default to all interfaces
        interfaces = interfaces if hasattr(interfaces, '__iter__') else [interfaces]

        for interface in interfaces:
            for f in self.filters:
                packet = f.tx(packet, interface)  # run outgoing packet through the filters
            if packet:
                # if not dropped, log the transmit and pass it to the interface's send method
                # self.log("OUT     ", ("<"+",".join(i.name for i in interfaces)+">").ljust(30), packet.decode())
                interface.send(packet)
1008150
protected void beforeSend(RpcInternalContext context, SofaRequest request) {
        currentRequests.incrementAndGet();
        context.getStopWatch().tick().read();
        context.setLocalAddress(localAddress());
        if (EventBus.isEnable(ClientBeforeSendEvent.class)) {
            EventBus.post(new ClientBeforeSendEvent(request));
        }
    }
846488
def _on_open(self, _):
        """"""
        nick = self._format_nick(self._nick, self._pwd)
        data = {"cmd": "join", "channel": self._channel, "nick": nick}
        self._send_packet(data)
        self._thread = True
        threading.Thread(target=self._ping).start()
1188908
public function beforeSend()
    {
        $this->client->beforeSend($this);

        $event = new RequestEvent();
        $event->request = $this;
        $this->trigger(self::EVENT_BEFORE_SEND, $event);
    }
1366074
function injectBefore(replServer, method, beforeFn) {
  var _orig = replServer[method];
  replServer[method] = function() {
    var args = Array.prototype.slice.call(arguments);
    var callback = args.pop();
    beforeFn.apply(null, args.concat(function(err, res) {
      if (err || res) {
        callback(err, res);
      } else {
        _orig.apply(replServer, args.concat(callback));
      }
    }));
  };
  return replServer;
}
1337217
private void handleInit(ChaincodeMessage message) {
        new Thread(() -> {
            try {

                // Get the function and args from Payload
                final ChaincodeInput input = ChaincodeInput.parseFrom(message.getPayload());

                // Mark as a transaction (allow put/del state)
                markIsTransaction(message.getChannelId(), message.getTxid(), true);

                // Create the ChaincodeStub which the chaincode can use to
                // callback
                final ChaincodeStub stub = new ChaincodeStubImpl(message.getChannelId(), message.getTxid(), this, input.getArgsList(), message.getProposal());

                // Call chaincode's init
                final Chaincode.Response result = chaincode.init(stub);

                if (result.getStatus().getCode() >= Chaincode.Response.Status.INTERNAL_SERVER_ERROR.getCode()) {
                    // Send ERROR with entire result.Message as payload
                    logger.severe(format("[%-8.8s] Init failed. Sending %s", message.getTxid(), ERROR));
                    queueOutboundChaincodeMessage(newErrorEventMessage(message.getChannelId(), message.getTxid(), result.getMessage(), stub.getEvent()));
                } else {
                    // Send COMPLETED with entire result as payload
                    if (logger.isLoggable(Level.FINE)) {
                        logger.fine(format(format("[%-8.8s] Init succeeded. Sending %s", message.getTxid(), COMPLETED)));
                    }
                    queueOutboundChaincodeMessage(newCompletedEventMessage(message.getChannelId(), message.getTxid(), result, stub.getEvent()));
                }
            } catch (InvalidProtocolBufferException | RuntimeException e) {
                logger.severe(format("[%-8.8s] Init failed. Sending %s: %s", message.getTxid(), ERROR, e));
                queueOutboundChaincodeMessage(newErrorEventMessage(message.getChannelId(), message.getTxid(), e));
            } finally {
                // delete isTransaction entry
                deleteIsTransaction(message.getChannelId(), message.getTxid());
            }
        }).start();
    }
257313
private void doBefore() throws Throwable { //NOSONAR

        this.repository = this.createRepository();
        doStateTransition(State.CREATED);
        this.initialize();
        doStateTransition(State.INITIALIZED);
    }
358147
private void preLog(RequestDTO request, byte[] reqBytes) {
        LOG.info(String.format("Navi rpc call start - %d\t%s\t%s\t%s\t%d", request.getTraceId(),
                url, request.getMethod(), serializeHandler.getProtocol().getName(),
                reqBytes == null ? 0 : reqBytes.length));
    }
366781
def _check_for_initial_packet_cb(self, data):
        
        self.state = State.CONNECTED
        self.link_established.call(self.link_uri)
        self.packet_received.remove_callback(self._check_for_initial_packet_cb)
1082468
private void deliver() {
    try {
      deliverUnsafe();
    } catch (Throwable t) {
      // This should never happen. If does, it means we are in an inconsistent state and should
      // close the stream and further processing should be prevented. This is accomplished by
      // purposefully leaving the lock non-zero and notifying the outerResponseObserver of the
      // error. Care must be taken to avoid calling close twice in case the first invocation threw
      // an error.
      innerController.cancel();
      if (!finished) {
        outerResponseObserver.onError(t);
      }
    }
  }
231742
def pre_send(self, request_params):
        """"""
        for adapter in itervalues(self.adapters):
            adapter.max_retries = request_params.get('max_retries', 0)

        return request_params
927299
@Override
	public final boolean packetReceived(AbstractPacket packet)
    {
        if (packet.getType() == PacketType.NOTIFICATION)
        {
            final NotificationPacket notifPacket = (NotificationPacket)packet;
            final AbstractMessage prefetchedMessage = notifPacket.getMessage();
            
            boolean acceptedByConsumer = false;
                
    		AbstractSession session = lookupRegisteredSession(notifPacket.getSessionId());
            if (session != null)
            {                   
                RemoteMessageConsumer consumer = (RemoteMessageConsumer)session.lookupRegisteredConsumer(notifPacket.getConsumerId());
                if (consumer != null)		
                    acceptedByConsumer = consumer.addToPrefetchQueue(prefetchedMessage,notifPacket.isDonePrefetching());
                else
                	log.debug("#"+id+" No such consumer : #"+notifPacket.getSessionId()+":"+notifPacket.getConsumerId()); // Consumer was concurrently closed or not yet registered
            }
            else
            	log.debug("#"+id+" No such session : #"+notifPacket.getSessionId()); // Session was concurrently closed
            
            // If the consumer was already gone, we need to rollback the prefetched message on the server side
            if (!acceptedByConsumer)
                scheduleRollback(notifPacket.getSessionId(),
                		         notifPacket.getConsumerId(),
                		         prefetchedMessage);
            
            return true;
        }
        
        if (packet.getType() == PacketType.R_PING)
        	return true;
        
        // Standard response, route to target endpoint
        transportHub.routeResponse((AbstractResponsePacket)packet);
        
        return true;
    }