使用带有 -p 选项的 netcat [英] Using netcat with -p option

查看:256
本文介绍了使用带有 -p 选项的 netcat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是通过以下方式使用netcat的

I used netcat in the following way

nc -l 3333    //for server

nc 127.0.0.1 3333  // for client

有了这个,我可以将其用作双向聊天系统.

With this I am able to use it as a two way chatting system.

我的问题是,那为什么还有另一个选择

My question is, then why is there another option

-p(-p source_port 指定 nc 应使用的源端口,受权限限制和可用性限制.)

-p ( -p source_port Specifies the source port nc should use, subject to privilege restrictions and availability.)

它也适用于 -p 选项.两者有什么区别?

It works with -p option too. What is the difference between the two?

推荐答案

一个 TCP 连接由两个 TCP 端点组成,每个端点由一个 IP 地址和一个 TCP 端口组成.客户端通常选择一个随机端口,尽管您可以使用 -p 选项强制 netstat 使用给定的端口.

A TCP connection consists of two TCP endpoints, each consisting of an IP address and a TCP port. The client usually chooses a random port, although you can force netstat to use a given port using the -p option.

试试:

adi@laps:~$ nc -l 3333 -p 4444
nc: cannot use -p and -l
adi@laps:~$ nc -l 3333 &
[1] 6025
adi@laps:~$ nc localhost 3333 -p 3333
nc: bind failed: Address already in use

这篇关于使用带有 -p 选项的 netcat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆