mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-26 10:53:25 +00:00
For TCP streams we used to have three states, e.g. `InitStream`, `ListenStream`, `ConnectedStream`. If the socket is not bound, it is in the `InitStream` state. If the socket is bound, it is still in that state. Most seriously, if the socket is connecting to the remote peer, but the connection has not been established, it is also in the `InitStream` state. While the socket is trying to connect to its peer, it needs to handle iface events to update its internal state. So it is expected to implement the trait that observes such events for this later. However, the reality that sockets connecting to their peers are mixed in with other unbound and bound sockets in the `InitStream` will complicate things. In fact, the connecting socket should belong to an independent state. It does not share too much logic with unbound and bound sockets in the `InitStream`. So in this commit we will decouple that and create a new `ConnectingStream` state.