Motorola AT Commands G24-L Technical Information Page 60

  • Download
  • Add to my manuals
  • Print
  • Page
    / 84
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 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.
Page view 59
1 2 ... 55 56 57 58 59 60 61 62 63 64 65 ... 83 84

Comments to this Manuals

No comments