c - Redirect STDIN to socket and socket to STDOUT -


I am trying to develop a simple command line client on the server. After connecting to the server and setting up everything properly, I want to redirect the STDIN to the server and the same socket on the STDOUT I want to get the same behavior as the nc device.

The easiest solution will be selected () and to read () / to write () From STDIN to the data socket and pass STDOUT from the socket. Does Socket anyway STDIN / STDOUT? Any other easy way to add to is dup2 () I thought about using the system call though, I'm not sure how it works.

Thank you.

On linux you can move data between file descriptor at the kernel level by splice ( 2) . However, you have to use (2) (or equivalent) to handle two directions in parallel, or optionally use two threads.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -