|
-
September 30th, 2000, 12:23 PM
#1
TCP/IP
Hi
I build an APPLET program that work with TCP/IP
i success to connect a server and i success to
send data to the server but the problem is
to recv text from the server only when i close
the server i get the data he send me.
The server send me data and i don't get the data
until i close the server and then i get all the data he send me.
here is the Thread that recv the data
class RecvThread extends Thread
{
Socket socket = null;
BufferedReader in = null;
String info;
TextArea text;
RecvThread(Socket s,BufferedReader i,TextArea t)
{
this.socket = s;
this.in = i;
this.text = t;
}
public void run()
{
try
{
while ((info=in.readLine())!=null)
{
text.setText(text.getText() + " " + info);
}
}
catch (IOException e)
{
}
}
}
Why ???
Thak You
i will rate.
-
October 1st, 2000, 03:31 PM
#2
Re: TCP/IP
There are two possibilities...
1. If you have developed server yourself and you have used buffered-stream for it, you should flush it after out-putting a line.
2. If the server is developed by someone else or doesn't use buffered-stream, it might not be sending line separator (\n), that's why readLine method keeps waiting for it. In this case try reading the data in bytes and then whatever you get, convert it to string as per your needs.
- UnicMan
http://members.tripod.com/unicman
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|