与服务器的部分连接完成,但不能总是从输入流中读取数据,只能读取一次。
public void startSSLClient() throws IOException {
inf = new Inflater();
mSocketBufferReader = new BufferedReader(new InputStreamReader(mSslSocket.getInputStream()));
new Thread() {
boolean online =false;
String s;
@Override
public void run() {
try {
while ( true ) {
String str = mSocketBufferReader.readLine();
if (!TextUtils.isEmpty(str)) {
Logger.e("PacketReader","process packet : "+str);
}
}
}
catch (Exception e) {
System.out.println("Error: " + e);
}
}
}.start();
}
如果我尝试这个,它总是从输入流中读取。
public void startSSLClient() throws IOException {
inf = new Inflater();
new Thread() {
boolean online =false;
String s;
@Override
public void run() {
try {
while ( true ) {
BufferedReader mSocketBufferReader = new BufferedReader(new InputStreamReader(mSslSocket.getInputStream()));
String str = mSocketBufferReader.readLine();
if (!TextUtils.isEmpty(str)) {
Logger.e("PacketReader","process packet : "+str);
}
}
}
catch (Exception e) {
System.out.println("Error: " + e);
}
}
}.start();
}
我不知道原因。我只想使用一个全局字段。我不想总是使用新的本地字段。