我用ncat启动ncat (在Windows 10上)
ncat -vvlp 1234 -e code.exe然后连接到第一个实例的ncat的第二个实例( ncat 127.0.0.1 1234 )。
code.exe是我写的一个C程序,可以通过stdin进行控制。 我通过第二个ncat发送的所有内容都被转发到code.exe的stdin。 我知道这是因为我可以在发送命令后看到code.exe创建文件夹。 但是直到code.exe关闭之后才会发送输出。
为什么 - 我该如何解决?
I start ncat (on Windows 10) with
ncat -vvlp 1234 -e code.exeand then connect with a second instance of ncat to the first instance (ncat 127.0.0.1 1234).
code.exe is a C program written by me that can be controlled over stdin. Everything I send via the second ncat gets forwarded to the stdin of code.exe. I know this because I can see code.exe create a folder after sending the command to do so. But the output is not send back until code.exe closes itself.
Why is that — and how can I fix it?
最满意答案
好吧,我找到了解决我的问题。 我通过使用禁用标准输出的缓冲
setbuf(stdout, NULL);在我的C程序开始。
Ok I found a solution to my problem. I disabled buffering of stdout by using
setbuf(stdout, NULL);at the start of my C program.
更多推荐
发布评论