5 ms·
I think the point is that a socket is doing both reading and writing using the same file descriptor, which is counterintuitive.
by greybrunix 3y ago
I think the point is that a socket is doing both reading and writing using the same file descriptor, which is counterintuitive.
- rnmmrnm 3y agoand that to half-close a socket you need to use some unintuitive syscall.
- pif 3y agoUse two pipes and you won't need to half-close any socket.
- Veserv 3y agoWhich is a problem of their own making. If they use two sockets, which would be needed if all three programs were on different machines, then it would work exactly the same as the pipe example. The problem is that they saw TCP sockets are two-way and then thought to optimize the TCP connection/state overhead by using it for double-duty without applying appropriate abstractions to transparently use a two-way channel as two one-way channels.
- Gabrys1 3y agoSome early protocols used two sockets for (maybe?) roughly this reason
- adontz 3y agoIf you mean FTP, then no. One socket is for commands, another is for data. Both bidirectional.
- dfawcus 3y agoCompare with what existed when NCP (RFC 33) was in use. An early FTP protocol (452, 454, 542) originally used a server listen port of 3 (and hence a server "return port" of 2*), but 542 allowed temporary use of port 21 as the protocol was changed. A different pair of ports (even or odd depending upon TX or RX end) were used for the data channel, and the port picked was related to the Telnet protocol port in use. RFC 640 then seems to have fixed the use of port 21 instead of 3. Then when TCP came in to use RFC 765 seems to have simplified things somewhat, sticking to port 21. Also see RFC 165 for the/a Telnet Initial Connection Protocol showing the use of the two even/odd ports for forming a bidirectional connection. * Or 4, but I believe the return channel was one port below, not above.
- adontz 3y agoI believe that's a different story explained here https://news.ycombinator.com/item?id=14178993 https://news.ycombinator.com/item?id=14178993
- dfawcus 3y agoSort of - NCP (RFC 33) had two simplex sockets. Even being receive, odd transmit. That then led to various higher level protocols using pairs of ports. Once TCP took over, that was relaxed.