How can one implement a connection to a serial terminal server? Sending data to the terminal server is easy but receiving data back from the terminal server is not as the receive command can't be aborted and the NWConnection is considered unusable once a receive has timed out as explained by @eskimo in this thread: https://developer.apple.com/forums/thread/120438.
Any NWConnection use case where the NWEndpoint represents a network media transition point (Ethernet->Serial in case of serial terminal server) must be ready to receive data but the time for receiving is not predictable and not receiving any data for an extended period of time is normal and does not reflect a failure at the NWEndpoint hence should not affect the NWConnection state.
This example becomes even more pertinent when the terminal server connects to a multi drop serial network (e.g. RS485) with multiple devices connected where some of the serial devices may not respond at all (e.g. when powered down). Combined with quick data update times (e.g. 100ms) the problem becomes insurmountable as cancelling the connection (to abort receive) every time a device doesn't respond, will cause lots of unnecessary network traffic.
The only solution I can think of is for NWConnection provide the ability to abort receive() without affecting the NWConnection.
For anyone that thinks "Serial is old, nobody uses it today" - There are tens of thousands of devices in industrial applications which use serial communications and it is essential that modern support software is made available on macOS.
Any suggestions would be much appreciated.