Motorola AT Commands G24-L Informazioni Techniche Pagina 60

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 84
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 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.
Vedere la pagina 59
1 2 ... 55 56 57 58 59 60 61 62 63 64 65 ... 83 84

Commenti su questo manuale

Nessun commento