Motorola AT Commands G24-L Informations techniques Page 60

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 84
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 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.
Vue de la page 59
1 2 ... 55 56 57 58 59 60 61 62 63 64 65 ... 83 84

Commentaires sur ces manuels

Pas de commentaire