本文介绍了Netcat:使用nc -l port_number而不是nc -l -p port_number的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题正在关注此问题:

This question is following this one: Sockets working in openSUSE do not work in Debian?

在Debian系统上使用套接字时,我必须使用nc -l -p port_number来模拟我想要的服务器和...谈谈如果我使用nc -l port_number,那么当使用套接字连接功能时,它会失败,而strerror(errno)会说Connection refused。

When working with sockets on my Debian system, I have to use nc -l -p port_number to simulate the server I want to talk with. If I'm using nc -l port_number, it will fail when using the socket connect function and strerror(errno) will say "Connection refused".

Netcat没有-p选项在其他Linux发行版上工作得很好,我应该在配置上改变什么?

Netcat without -p option is working great on other Linux distributions, what should I change on my configuration?

推荐答案

我同意,只需使用 -p 选项,但要回答您的问题:

I agree with duskwuff that it is better to just use the -p option everywhere, but to answer your question:

你必须做的一件事是安装一个支持你想要的语法的netcat。我知道 netcat-openbsd 包支持它。我知道 netcat-traditional 包不。还有一个 netcat6 包,也没有。然后,您可以明确请求OpenTCD版本的netcat,如下所示:

The one thing you have to do is install a netcat that supports the syntax you want. I know the netcat-openbsd package supports it. I know the netcat-traditional package does not. There's also a netcat6 package, which also doesn't. You can then explicitly request the OpenBSD version of netcat like so:

nc.openbsd -l 4242

可选地,您可以使用备用系统来设置此版本的netcat,以便在发布 nc 命令:

Optionally you may use the alternatives system to set this version of netcat to run when you issue the nc command:

update-alternatives --set nc /bin/nc.openbsd

如果这是您安装的唯一netcat,这将自动完成。

This will be done automatically for you if this is the only netcat you've installed.

最后,您可以再次选择删除不喜欢的网络摄像头( netcat-traditional netcat6 )。

Finally, you may, again optionally, remove the netcat you don't like (netcat-traditional or netcat6).

这篇关于Netcat:使用nc -l port_number而不是nc -l -p port_number的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 15:49