Windows上的ncat:

编程入门 行业动态 更新时间:2024-10-27 18:28:25
Windows上的ncat:-e选项转发输入,但不转发输出(ncat on windows: -e option forwards input but does not forward output)

我用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.exe

and 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.

更多推荐

本文发布于:2023-07-26 19:21:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1279860.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Windows   ncat

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!