import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
public class TCPdome {
public static void main(String[]args) throws Exception{
ServerSocket Sst =new ServerSocket(8190);
Socket Sk =Sst.accept();
BufferedReader Ips =new BufferedReader(new InputStreamReader(Sk.getInputStream()));
String s ="";
while((s =Ips.readLine())!=null){
System.out.println(s);
}
}
}
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.FileReader;
import java.net.Socket;
public class tcpkh{
public static void main (String[]args) throws Exception{
Socket sck =new Socket("127.0.0.1",8190);
BufferedReader Brd =new BufferedReader(new FileReader("D:\\Java\\src\\com\\bjsxt\\tank\\Tank.java"));
String s =null;
while((s=Brd.readLine())!=null){
DataOutputStream bfs =new DataOutputStream(sck.getOutputStream());
bfs.writeBytes(s);
// bfs.close();
}
// Brd.close();
// sck.close();
}
}
Exception in thread "main" java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
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 TCPdome.main(TCPdome.java:15)
爆这个错误,请大神帮忙看看 |