Macos 通过终端中的端口直接发送消息

Macos 通过终端中的端口直接发送消息,macos,command-line,terminal,Macos,Command Line,Terminal,基本上,我保存了一个连接到特定端口的命令,以便用另一个Mac在终端中发送消息 $ nc -n -v -l (port) $ nc -n -v (ip) (port) # --> When the .command file is opened, will run directly. 但是,当.command文件打开时,整个提要就停止了。我希望它立即发送消息,然后关闭连接。如果要保持连接侦听,代码将是什么?您将使用-kl(保持侦听) 使用其他连接,您可以通过以下方式立即发送数据并关闭连

基本上,我保存了一个连接到特定端口的命令,以便用另一个Mac在终端中发送消息

$ nc -n -v -l (port)

$ nc -n -v (ip) (port) # -->  When the .command file is opened, will run directly.

但是,当.command文件打开时,整个提要就停止了。我希望它立即发送消息,然后关闭连接。如果要保持连接侦听,代码将是什么?您将使用
-kl
(保持侦听)

使用其他连接,您可以通过以下方式立即发送数据并关闭连接:

nc -n -v (ip) (port) < <(echo "hello, world!")

nc-n-v(ip)(端口)<如果要保持连接侦听,请使用
-kl
(保持侦听)

使用其他连接,您可以通过以下方式立即发送数据并关闭连接:

nc -n -v (ip) (port) < <(echo "hello, world!")
nc-n-v(ip)(端口)<