java socket网络编程遇见的问题,急 5
大家都知道要实现客户机与服务器通信一般采用的办法是socket编程,目前我想实现本地计算机向远程服务器发送命令,远程服务器实现了SocketServer但是在本机发送命令...
大家都知道要实现客户机与服务器通信一般采用的办法是socket编程,目前我想实现本地计算机向远程服务器发送命令,远程服务器实现了SocketServer但是在本机发送命令过去的时候,如果采用的是普通的CMD命令,那么那边是可以执行的,但是如果采用这样的命令,"net start serverName",然后就会出现下面的错误,请问是怎么回事呢?
错误代码是
java.io.IOException: Cannot run program "net": CreateProcess error=5, ???·?
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at DOSCommand.getMACAddress(DOSCommand.java:17)
at MyServer.main(MyServer.java:12)
Caused by: java.io.IOException: CreateProcess error=5, ???·?
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 6 more
Exception in thread "main" java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at java.io.InputStreamReader.read(Unknown Source)
at java.io.BufferedReader.fill(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
at MyServer.main(MyServer.java:13) 展开
错误代码是
java.io.IOException: Cannot run program "net": CreateProcess error=5, ???·?
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at DOSCommand.getMACAddress(DOSCommand.java:17)
at MyServer.main(MyServer.java:12)
Caused by: java.io.IOException: CreateProcess error=5, ???·?
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 6 more
Exception in thread "main" java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at java.io.InputStreamReader.read(Unknown Source)
at java.io.BufferedReader.fill(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
at MyServer.main(MyServer.java:13) 展开
2个回答
展开全部
试试在前面加cmd /c 即像下面这样
cmd /c net start serverName
cmd /c net start serverName
追问
还是一样的,cmd /c 这个起什么作用呢?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询