• Post Reply Bookmark Topic Watch Topic
  • New Topic

not able read from socket  RSS feed

 
Shweta Grewal
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to receive multiline input from socket.So I write the code:
String line=null;
FromServer=new String();
while((line = inFromServer.readLine())!=null){
FromServer+=intr;
intr=new String("");
}
But I get stuck. any suggestions please?
 
Shweta Grewal
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please help
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be patient.

Where you are stuck? Please read ItDoesntWorkIsUseless.
 
Shweta Grewal
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I enter the while loop but doesn't come out. Even the loop gets stuck after first time, never works a second time
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be the inFromServer.readLine() is waiting for response from the server to the socket.
 
Shweta Grewal
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be the inFromServer.readLine() is waiting for response from the server to the socket.

Sorry didn't get you.
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The readLine method waits until the server echoes the information back to EchoClient

Source - Reading from and writing to Sockets
 
Shweta Grewal
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
still didn't get it
will you please explain it in simple words
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, what *did* you understand from the document John linked to? If this is your first time using Java sockets, then you should work though the entire Java Tutorial section; start at http://docs.oracle.com/javase/tutorial/networking/sockets/index.html
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!