public class Jgtz extends Thread{
private Socket s;
private static int next = 0;
public Jgtz(Socket s){
this.s=s;
}
public void run(){
try{ OutputStream os=s.getOutputStream();
InputStream is=s.getInputStream();
byte[] buf=new byte[800];
os.write("热烈欢迎!".getBytes("GBK"));//发送至client端的数据
int len=is.read(buf);
String Msg = new String(buf,0,len);//得到client端传过来的数据
System.out.println("Msg==="+Msg);
                           //我想发送的是os.write("热烈欢迎!"+Msg.getBytes("GBK"));
                           //然而语句放在这程序好像阻塞了,server端与client端都获取不到数据了!
    os.close();
    is.close();
s.close();
}catch (Exception ex){
ex.printStackTrace();
}
}
public static void main(String[] args){
server();
}
public static void server(){
try{
ServerSocket ss=new ServerSocket(6000);
while(true){
Socket s = ss.accept();
new Jgtz(s).start();
}
    }catch (Exception ex) {
     ex.printStackTrace();
    }
}
}上面是server端的代码,我想server接受了client端的数据后,再加上server的一些数据一并回传给client端。然而
os.write("热烈欢迎!".getBytes("GBK"));
int len=is.read(buf);
上面两句却不能调换位置,否则程序阻塞!