服务器和客户端程序哪里错了??
为什么这个服务器程序打印不出“5”????import *;
import *;
class Server
{
public Server()
{
try
{
ServerSocket ss=new ServerSocket(6000);
Socket s=ss.accept();
System.out.println("1");
InputStream in=s.getInputStream();
OutputStream out=s.getOutputStream();
System.out.println("2");
BufferedReader BR=new BufferedReader(new InputStreamReader(in));
PrintWriter PP=new PrintWriter(out,true);
System.out.println("3");
String str=BR.readLine();
System.out.println("4");
PP.println("服务器已经接收到请求!!");
while(str!=null)
{
System.out.println(str);
str=BR.readLine();
}
System.out.println("5");
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
Server s=new Server();
}
}
为什么这个客户端程序打印不出“aaaa”????
import *;
import *;
class Client
{
public Client()
{
try
{
Socket s=new Socket(InetAddress.getByName(null),6000);
System.out.println("1");
InputStream in=s.getInputStream();
OutputStream out=s.getOutputStream();
System.out.println("2");
BufferedReader BR=new BufferedReader(new InputStreamReader(in));
PrintWriter PW=new PrintWriter(out,true);
System.out.println("3");
PW.println("客户端已经接收到回应!!");
System.out.println("4");
String str=BR.readLine();
System.out.println("5");
while(str!=null)
{
System.out.println(str);
str=BR.readLine();
}
System.out.println("aaaa");
}catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
Client s=new Client();
}
}