开发者

Android Socket Not Playing Nice

As Title.

Here is code:

InputStream is = tcp.getInputStream();
            int bytesRead = 0;
            do{
                byte[] byteIn = new byte[16* 1024];
                bytesRead = is.read(byteIn, 0, 16*1024);
                pStore.storeData(b开发者_C百科yteIn, 1024); 
                processMessage(pStore.readAll());
                pStore.clear();             
            }while(bytesRead>0);

Problem I have is that it never reaches the end of the while loop. Any suggestions would be muchly appreciated.

Thanks :)


The Javadoc to InputStream.read() says:

This method blocks until input data is available

Which is what you may be seeing.

You may test with InputStream.available() if there is any data to be read first.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜