XmlPullParse how to read network stream

in the project,

focusing on the SocketReader class, when the client “openStream()” and send initial <stream:stream …> packet to the server.the server can create session successfully,but following in “readstream()” the function call “reader.parseDocument()”,and in the “parseDocument()” function “type = pp.nextToken();” will get a “type” value 3,it’'s “End-Tag”,then “reader.parseDocument().getRootElement()” will return null,and break the function “readStream()” and the packetReader thread closed.

I think it’'s a error,and I hope that the reader first read the initial "stream:stream.... packet to create session, then in the parseDocument will wait later coming packet and then parse,why not?

that’‘s my question, and be puzzled for a long time. thanks very much for your’'s instruction!!!

i corrected