Java socket, client hangs when get input from server output -


i have socket in client connects server send , receive string, uses writeutf() , readutf() read , write socket, when write string client socket , read them on server it's work. when server receive string socket , write "flag" socket read them on client client hang @ read line. here code.

server

public void run(){     datainputstream input = null;     try{         output = new dataoutputstream(socket.getoutputstream());         input = new datainputstream(socket.getinputstream());         while((true)&&(this.active)){             string receive = input.readutf();                            string[] str = receive.split("@");             if (str[0].equals("get_list")){                                     output.writeutf("flag");                               }          }     }catch(ioexception ex){     } 

client

public void run(){    dataoutputstream output = null;     try{         output = new dataoutputstream(socket.getoutputstream());         datainputstream input = new datainputstream(socket.getinputstream());         output.writeutf("get_list@");                   string receive = input.readutf();   //hang @ line         system.out.println(receive);     } catch (ioexception ex) {     } 


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -