网路编程
/***************服务端**************/
SeverSocket seversocket=new SeverSocket("端口号1"); /****范围是1024~9999******/
/*侦听数据*/
Socket socket=seversocket.accept();
InputStream is=socket.getInputStream();
BufferdReader br=new BufferdReader(new InputStreamReader(is:“InputStream的对象名”));
/*读取客户端的信息*/
String info=null;
While((info=br.readLine())!=null){
System.out.println("服务器说"+info);
}
/*给客户端写回应*/
OutputStream os=socket.getOutputStream();
String answer="我是服务器,客户端你好";
os.write(answer.getbytes);
br.close();
is.close();
seversocket.close();