Gone through the couple of already discussed similar questions here but still not clear on the relationship between a "TCP Connection" & A Stream (Data) or May be TCP Sequence (which wireshark generates ), I have server which controls that there will be only one connection created at a time while communicating with target server, application will be look up for the connection in connection pool, get one and start sending data to target server using the same connection, once the data is sent it will be FIN ACK and close the connection or return the connection to connection pool.
It works fine however during the "closing connection" phase of TCP connection, there is another message which will be picked by application and since the connection is not fully closed yet, the next message is being sent to server over the same connection, however meantime the original connection will get closed as initiated during the previous message processing so the response for the new message is not reaching to client server due to connection closer!!
In above scenario, the only catch is the "output Stream" of the connection is being released as soon as there is ACK for application data transfer for output stream, making it available for the next message to use and send data to server ?
My question is - Is there any logical "one to tone" relationship between TCP connection and output stream ( I understand, stream will be ceated only if conneciton is there) , for example lets say I don't release the stream back as soon as data is sent to server, Will this mean that even if next message comes into application and since connection is active , it will not be able to send the message to server because the stream is not available ? or it will create a "New" stream to send the data anyway ? establishing there is not one to one relationship between one TCP connection and output / input stream ? and only way to handle this would be control the message processing one by one ?
or if the steam is released as it is being , not closing connection ever will work.
Note - The server side has the challenge in handling multiple connections on same port from same client so the limitation of one connection at a time.
Expectation is that next message should not get lost!!