Using Sockets with BufferedInputStream
Hi,
Many thanks in advance for any help or advice. I have been struggling with this for a while now.
I have data comming in from a Socket. I create a BufferedInputStream like this:
inputStream =new BufferedInputStream( socket.getInputStream() );
The class that this code is in extends Thread, and in the run method i have:
while(true )
{
try
{
inputSource =new InputSource( inputStream );
responseXML.parseClientData( inputSource, client.getID() );
}
catch( Exception e )
{
System.out.println("run.Error: " + e );
}
}
The class responseXML takes the stream and tries to parse the XML as follows:
publicvoid parseClientData( InputSource dataFromFlash,int clientID )
{
System.out.println("parseClientData" + clientID );
try
{
xmlReader.parse( dataFromFlash );
}
catch( Exception e )
{
System.out.println("parseClientData.Error: " + e );
}
}
My problem:
The above method (parseClientData) is getting called over and over again - it is stuck in an infinite loop.
And this error is caught in the above methodt:
parseClientData.Error: java.io.IOException: Stream closed
Any ideas? I have been struggling with this for far too long.
I thnik it might be to do with blocking and non-blocking input streams.
When i used a noraml BufferedReader - i didn't have this problem.
Thanks.
Regards, Custom
Message was edited by:
custom
Message was edited by:
custom

