Windows BAT 或 CMD:将一些数据发送到 localhost udp 端口 [英] Windows BAT or CMD: send some data to a localhost udp port
问题描述
我有一个监听本地主机端口的应用程序.我想要一个最小的启动器来将该应用程序放在最前面.
I have an app that listens on a localhost port. I want a minimal launcher to bring that app's to the front.
我的应用程序是 Java.我不知道怎么写任何exe文件,但是我可以写bat文件,然后做一个快捷方式来启动bat文件而不显示终端.我想让 bat 文件向端口发送一些数据(最好是 UDP,这样不会有任何流开销).
My app is in Java. I don't know how to write any exe files, but I can write bat files, and then make a shortcut that launches the bat file without showing the terminal. I would like to have the bat file send some data to a port (preferably UDP so there will not be any stream overhead).
如何将数据发送到 UDP 端口?
How can I send data to a UDP port?
我想到的一件事是 nslookup
,但据我所知,它只会连接到端口 53.
One of the things I thought of was nslookup
, but that will only connect to port 53 as far as I know.
这只需要在 Windows 上工作.希望它可以在 XP 及更高版本上运行,但如有必要,我可以制定解决方法.
This only needs to work on Windows. Would like it to work on XP and up, but I can make a workaround if necessary.
推荐答案
这是netcat的工作.
This is a job for netcat.
安装后,您可以轻松地从命令行启动它或编写一个 BAT 脚本来为您执行它.要通过 UDP 而不是 TCP 发送日期,请使用-u"开关.
After installing you can easily launch it from the command line or write a BAT script to execute it for you. To send date through UDP rather than TCP, use the "-u" switch.
例如,要将数据发送到本地主机上的 UPD 端口 2345,请执行:
For example, to send the data to UPD port 2345 on localhost execute:
nc -u localhost 2345
然后输入您要发送的数据.
Then type the data you want to send.
这篇关于Windows BAT 或 CMD:将一些数据发送到 localhost udp 端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!