Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

readLine with socket

Status
Not open for further replies.

Grentis

Programmer
Aug 18, 2003
13
IT
Hi,
I use a socket to connect with a server mail. The problem is that I can send messages to it but I can't read the response. My DataInputStream wait infinitely a response and so the program can't continue...
I use i.readLine() to read the response.
How can I resolve this problem?
Thanks

grentis
 
try with following code
DataInputStream dis = new DataInputStream(System.in);
String str;

PrintWriter out=new PrintWriter(sock.getOutputStream(),true);
DataInputStream sdis = new DataInputStream(sock.getInputStream());
do{

System.out.println("enter string");
str=dis.readLine();

out.println(str);


if(str.equals("eot"))
break;
str = sdis.readLine();
System.out.println(str);
}while(true);

sock.close();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top