问题描述
我有一个应用程序监听本地端口。我想要一个最小的启动器把这个应用程序带到前面。
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上工作。
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端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!