Motorola AT Commands G24-L Informacje Techniczne Strona 60

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 84
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 59
Standard Classes Deviations
5-18 G24 KJAVA User’s Guide July 15, 2008
while (true) {
int len = is.read(ReceiveData);
if (len > -1) {
//receive data
System.out.println("Receive data - " + new
String(ReceiveData) + "\n");
System.out.println("Number of bytes - " + len +
"\n");
} else if (len == -1) {
//connection with client has been broken.
openConnection(getAppProperty("PORT"));
}
}
} catch (IOException e) {
...
}
}
private void openConnection(String port) {
try {
//create ServerSocketConnection instance
scn = (ServerSocketConnection) Connector.open("socket://:" + port);
//wait for client connection.
sc = (SocketConnection) scn.acceptAndOpen();
sc.setSocketOption(SocketConnection.LINGER, 5);
} catch (IOException e) {
//cannot open connection
...
}
}
}
Note: In order to open more sockets in parallel, use another TcpConnection thread.
Przeglądanie stron 59
1 2 ... 55 56 57 58 59 60 61 62 63 64 65 ... 83 84

Komentarze do niniejszej Instrukcji

Brak uwag