请帮忙, 当我发送tcp数据包时,它只被接受了 第一次但是之后...... tcp包发送者 我使用告诉我数据包已发送 但该计划没有回应
public void run() {
try
{
ServerSocket ss = null;
try {
ss = new ServerSocket(message.getPort());
//ss.setSoTimeout(10000);
System.out.println("before loop");
while (true) {
Looper.prepare();
System.out.print("in");
Socket s = ss.accept();
System.out.print("out");
InputStreamReader in = new InputStreamReader(s.getInputStream());
int i;
String Msg = "";
while((i=in.read())!=-1)
{
System.out.println((char)i);
Msg += (char)i;
}
System.out.println(Msg);
for (GotResponseListener listener : listeners)
{
// Looper.prepare();
listener.onGotResponse(Msg);
System.out.println("Raised");
// Looper.loop();
}
Looper.loop();
}
} catch (InterruptedIOException e) {
//if timeout occurs
// e.printStackTrace();
} catch (IOException e) {
// e.printStackTrace();
} finally {
if (ss != null) {
try {
ss.close();
} catch (IOException e) {
// e.printStackTrace();
}
}
}
} catch (Exception ex) {
message.setText("r");
ex.printStackTrace();
}
}