Java Communication Server Client with Socket -


i'm having trouble client/server program in java . i'm able communicate client server when i'm broadcasting server client it's not working. there part of program not working : server :

 while (true) {             socket socket = server.accept();               out = new bufferedwriter(new outputstreamwriter(socket.getoutputstream()));             out.write("welcome server !");             out.flush(); } 

client ( running thread):

    while(true){      try { //s socket connection server            in = new bufferedreader (new inputstreamreader (s.getinputstream()));                  string msg = in.readline();                  system.out.println(msg);       } catch (ioexception ex) {       }              } 

when use client programm don't receive message sent server . when use netcat on terminal establish connection on server, got message . don't it. thanks

the client expects complete line sent:

string msg = in.readline(); 

it can sure line complete if finds line terminator character, or if stream closed. server doesn't send eol character, , doesn't close stream either. client keeps waiting line complete.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -