4 ms·
Yes. TCP connection establishment inherently forms a two-way channel between two entitys. There is little reason to duplicate the connection/routing (in the gen
by Veserv 3y ago
Yes. TCP connection establishment inherently forms a two-way channel between two entitys. There is little reason to duplicate the connection/routing (in the generic sense) establishment for each direction in the general case where you might want a two-way channel.
The problem in the presented example is that there are, fundamentally, 3 communicating entitys A->B->C, which logically demands two channels. A quirk of the example where A and C happen to be on the same system and coincidentally can use the channel disjointly (read-only and write-only) in conjunction with TCP being inherently two-way allows it to be kludged into a single channel, but frankly it is your fault for relying on bizarre implementation details [1].
If you want a proper abstraction, what you would actually do is multiplex multiple logical streams over a single duplex channel. The code would then operate purely on the logical streams (pipe-like) and everything would be clean. The implementation would then only need to establish connection once, removing the inherent overhead associated with establishing multiple network protocol connections, while still giving you a clean and consistent abstraction (barring the standard leakiness of the TCP abstraction).
[1] https://xkcd.com/1172/ https://xkcd.com/1172/