After some time of playing around inside my app with aStreams and sockets, I found out something that I missed at first look and was causing occasional problems:
While a socket can be closed, and the corresponding streams can be closed, it takes some time for the streams to really close! Thus, if for example, you're closing both, and then reusing the closed socket for a new connection, the streams (which were supposed to be closed) throw out a delayed terminated event, producing error.
I've changed my code, because I'm using many simultaneous open sockets, in order to prevent a hanged socket due to a delayed streams close, so now I have many sockets but NOT with the same index for streams (for e.g. I can have socket1(0) with astreams(1) or socket(1) with astreams(0) and so on).
Yet, I am wondering, is this an unavoidable property of streams (os)?
While a socket can be closed, and the corresponding streams can be closed, it takes some time for the streams to really close! Thus, if for example, you're closing both, and then reusing the closed socket for a new connection, the streams (which were supposed to be closed) throw out a delayed terminated event, producing error.
I've changed my code, because I'm using many simultaneous open sockets, in order to prevent a hanged socket due to a delayed streams close, so now I have many sockets but NOT with the same index for streams (for e.g. I can have socket1(0) with astreams(1) or socket(1) with astreams(0) and so on).
Yet, I am wondering, is this an unavoidable property of streams (os)?