java Ping 服务器和 Ping 客户端 (UDP)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14271185/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ping Server and Ping Client (UDP)
提问by Green Toad
I am studying ping server and ping clients using UDP and I found java codes on line. http://www.daimi.au.dk/~carl/Uge6/PingClient.javaI run it using eclipse and it requires 3 arguments. What are those arguments and where should they be placed? I think the port number and the IP address are arguments but whenever I try to place them in args[0], args[1]
, the code is still not running.
我正在研究使用 UDP 的 ping 服务器和 ping 客户端,我在网上找到了 java 代码。http://www.daimi.au.dk/~carl/Uge6/PingClient.java我使用 eclipse 运行它,它需要 3 个参数。这些论点是什么?应该把它们放在哪里?我认为端口号和 IP 地址是参数,但是每当我尝试将它们放入args[0], args[1]
.
Thank you very much!
非常感谢你!
回答by unnamed
As far as I can see, it requires 2 arguments. Address and port. I run it like that
据我所知,它需要 2 个参数。地址和端口。我这样运行
java PingClient [ADDRESS] [PORT]
and it works.
它有效。
Maybe I misunderstood your questions. What exactly is the error?
也许我误解了你的问题。究竟是什么错误?
回答by Jonathan Lermitage
you're right, you have to use an address and a port (as explain in the source code comments). There are 2 arguments, not 3.
您说得对,您必须使用地址和端口(如源代码注释中所述)。有 2 个参数,而不是 3 个。
"the code is still not running" => what happens ? An error, an exception ? Nothing ? How do you test the client and server programs ?
“代码仍未运行” => 会发生什么?一个错误,一个异常?没有什么 ?你如何测试客户端和服务器程序?
回答by Mehrnoosh
command line arguments are arguments that you can pass to your java class through command line.In this case for example you should write "java PingClint www.google.com 80" in your cmd
命令行参数是您可以通过命令行传递给 java 类的参数。例如,在这种情况下,您应该在 cmd 中写入“java PingClint www.google.com 80”