Я пытаюсь выполнить процедуру переподключения с сокетом, но безуспешно.Когда я останавливаю и перезапускаю сервер, клиент закрывает соединение, но не могу его сбросить.Любое предложение?
Это образец:
private void StartSocket(String IP, String port) {
execsocket = true;
st = new SocketTask(IP, Integer.parseInt(port), 5000) {
@Override
protected void onProgressUpdate(String... progress) {
recived = subst_emoticon(progress[0]);
Log.d("Rec", recived);
String cmd = "";
if (!recived.isEmpty()) {
if (recived.length() >= 4) {
cmd = recived.substring(0, 4);
}
if (cmd.equals("ERRO")) {
String[] parts = recived.split(";");
if (parts[0].equals("ERROR1")) {
if (!Repetir) {
if (MsgBox("No connection", "Working in offline?", "No", "Yes")) {
offline = true;
IP = "0";
Send("!LOG;" + Usuario + ";" + Senha);
} else
finish();
}
}
if (parts[0].equals("ERROR2")) {
if (MsgBox("Lost connection", "Retry?", "No", "Yes")) {
**//Routine for retry connection //**
}
}
}
Спасибо !!