سؤال

I have two file descriptors created with socket() and both are connected to separate hosts. I want anything received on the first socket to be immediately sent on the second and vice versa.

I know can achieve this manually with a combination of select(), send() and recv(), but is there a more direct way to tell the kernel to simply pipe the output from one into the other?

هل كانت مفيدة؟

المحلول

No. You can use a tool like netcat which does this for you (so you don't have to write the code) but even netcat contains a loop that copies the data.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top