- package ip.test;
- import java.io.*;
- import java.net.*;
- public class TcpClient
- {
- public static void main(String[] args)throws Exception
- {
- Socket s =new Socket("192.168.1.102",10004);
-
- OutputStream out = s.getOutputStream();
-
- out.write("wo lai le".getBytes());
-
-
- s.close();
- }
-
- }
复制代码 运行时报错!!!
- Exception in thread "main" java.net.ConnectException: Connection refused: connect
- at java.net.PlainSocketImpl.socketConnect(Native Method)
- at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
- at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
- at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
- at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
- at java.net.Socket.connect(Socket.java:519)
- at java.net.Socket.connect(Socket.java:469)
- at java.net.Socket.<init>(Socket.java:366)
- at java.net.Socket.<init>(Socket.java:180)
- at ip.test.TcpClient.main(TcpClient.java:10)
复制代码
这个应该怎么破?!
|
|