Ejemplo n.º 1
0
  public void dataReceived(Transport t) {
    aa(this, isReceiver(), "DATA received by non receiver socket");
    aa(this, isConnected(), "DATA received by invalid socket state");

    int inSeqNum = t.getSeqNum();

    p(this, 3, "dataReceived() seqnum: " + inSeqNum);
    transportBuffer.put(inSeqNum, t);
    deliverToBuffer();

    dumpState(4);
    p(this, 3, "ending dataReceived");

    tcpMan.sendACK(this.tsid);
  }
Ejemplo n.º 2
0
  /**
   * Accept a connection on a socket
   *
   * <p>Needs to trigger sending an ACK
   *
   * @return TCPSock The first established connection on the request queue remove from welcomeQueue
   *     adds recvSocket to socketSpace sends Ack
   */
  public TCPSock accept() {
    aa(this, this.sockType == SocketType.WELCOME, "accept() called by non-welcome socket");
    aa(this, this.state == State.LISTEN, "accept() called when not listening");

    if (welcomeQueue.isEmpty()) return null;

    p(this, 3, "accept()");
    TCPSock recvSock = welcomeQueue.remove(0);
    recvSock.state = State.ESTABLISHED;
    p(recvSock, 4, "established");
    tcpMan.add(recvSock.tsid, recvSock);
    tcpMan.sendACK(recvSock.tsid);

    return recvSock;
  }