I'm doing a project where I want a server to stream ncurses data (ascii) to a client.
The ncurses newterm() function takes a C style file descriptor, which is where it sends the generated ascii codes (default fd is stdout). I'm stuck on how to get from here to sending to the client.
I can think of two possibilities:
Let a byte buffer emulate a file descriptor and give newterm() this "fake" file descriptor. If this works, it should then be easy (I hope) to send the contents of the buffer to the client. But I don't know if it's possible to emulate a file descriptor in this way. (Googling didn't help me.)
Connect the file descriptor in newterm() directly to a socket in some way, if this is possible.
I'm totally new to Swift, but know some C (so I'm ok with the C types if I could just get them to work with Swift...). Also, I understand that there are different socket libraries available -- is Swift NIO the best one to use for me? I'm using Swift 4.2 so I'm limited to Swift NIO 1 -- is this a problem? I could upgrade to 10.14 in order to get Swift 5 + Swift NIO 2 if that would help.
Any help would be much appreciated!