3.9. Event Processing (Part 2)
CLOSE Call
CLOSED STATE (i.e., TCB does not exist)
If the user should no have access to such a connection, return "error: connection illegal for this process".
Otherwise, return "error: connection does not exist".
LISTEN STATE
Any outstanding RECEIVEs should be returned with "error: closing" responses. Delete TCB, return "ok".
SYN-SENT STATE
Delete the TCB and return "error: closing" responses to any queued SENDs, or RECEIVEs.
SYN-RECEIVED STATE
Queue for processing after entering ESTABLISHED state or segmentize and send FIN segment. If the latter, enter FIN-WAIT-1 state.
ESTABLISHED STATE
Queue this until all preceding SENDs have been segmentized, then form a FIN segment and send it. In any case, enter FIN-WAIT-1 state.
FIN-WAIT-1 STATE
FIN-WAIT-2 STATE
Strictly speaking, this is an error and should receive a "error: connection closing" response. An "ok" response would be acceptable, too, as long as a second FIN is not emitted (the first FIN may be retransmitted though).
TIME-WAIT STATE
Strictly speaking, this is an error and should receive a "error: connection closing" response. An "ok" response would be acceptable, too. However, since the FIN has been sent and acknowledged, nothing should be sent (or retransmitted).
CLOSE-WAIT STATE
Queue this request until all preceding SENDs have been segmentized; then send a FIN segment, enter CLOSING state.
CLOSING STATE
Respond with "error: connection closing"
ABORT Call
CLOSED STATE (i.e., TCB does not exist)
If the user should no have access to such a connection, return "error: connection illegal for this process".
Otherwise return "error: connection does not exist".
LISTEN STATE
Any outstanding RECEIVEs should be returned with "error: connection reset" responses. Delete TCB, return "ok".
SYN-SENT STATE
Delete the TCB and return "reset" responses to any queued SENDs, or RECEIVEs.
SYN-RECEIVED STATE
Send a RST of the form:
<SEQ=SND.NXT><ACK=RCV.NXT><CTL=RST,ACK>
and return any unprocessed SENDs, or RECEIVEs with "reset" code, delete the TCB.
ESTABLISHED STATE
Send a reset segment:
<SEQ=SND.NXT><ACK=RCV.NXT><CTL=RST,ACK>
All queued SENDs and RECEIVEs should be given "reset" responses; all segments queued for transmission (except for the RST formed above) or retransmission should be flushed, delete the TCB.
FIN-WAIT-1 STATE
FIN-WAIT-2 STATE
A reset segment (RST) should be formed and sent:
<SEQ=SND.NXT><ACK=RCV.NXT><CTL=RST,ACK>
Outstanding SENDs, RECEIVEs, CLOSEs, and/or segments queued for retransmission, or segmentizing, should be flushed, with "connection reset" notification to the user, delete the TCB.
TIME-WAIT STATE
Respond with "ok" and delete the TCB.
CLOSE-WAIT STATE
Flush any pending SENDs and RECEIVEs, returning "connection reset" responses for them. Form and send a RST segment:
<SEQ=SND.NXT><ACK=RCV.NXT><CTL=RST,ACK>
Flush all segment queues and delete the TCB.
CLOSING STATE
Respond with "ok" and delete the TCB; flush any remaining segment queues. If a CLOSE command is still pending, respond "error: connection reset".
STATUS Call
CLOSED STATE (i.e., TCB does not exist)
If the user should no have access to such a connection, return "error: connection illegal for this process".
Otherwise return "error: connection does not exist".
LISTEN STATE
Return "state = LISTEN", and the TCB pointer.
SYN-SENT STATE
Return "state = SYN-SENT", and the TCB pointer.
SYN-RECEIVED STATE
Return "state = SYN-RECEIVED", and the TCB pointer.
ESTABLISHED STATE
Return "state = ESTABLISHED", and the TCB pointer.
FIN-WAIT-1 STATE
Return "state = FIN-WAIT-1", and the TCB pointer.
FIN-WAIT-2 STATE
Return "state = FIN-WAIT-2", and the TCB pointer.
TIME-WAIT STATE
Return "state = TIME-WAIT and the TCB pointer.
CLOSE-WAIT STATE
Return "state = CLOSE-WAIT", and the TCB pointer.
CLOSING STATE
Return "state = CLOSING", and the TCB pointer.