Gemalto is now part of the Thales Group, find out more.

You are here

Interrupting blocking IO calls | Thales IoT Developer Community

jeroen.vandooren

March 24, 2015 - 6:08pm, 3910 views

Dear Gemalto,

we're in the process of implementing a TCP socket connection from a EHS6 to a cloud server. The vast majority of the code is done and is now is the maturing phase.

1. I've noticed that the Connector.open() accepts a third parameter indicating timeouts, which is only a hint. After testing that parameter and connecting to a bogus address, the open() method never timed-out and is blocking any other operations.

Is it possible by any call to unblock this .open() call (there is no object to call .close on)?

2. I've noticed that after having a connection via Connector.open(), you can open an outputstream. This outputstream can be used to write bytes to the remote side. However, this is also a blocking call, which can block indefinitly at any point in time, since a GSM network is hostile per definition.

Is it possible by any call to unblock this .write() call (by SocketConnection.close()?) or is there a write call with timeout?

3. I've noticed that after having a connection via Connector.open(), you can open an inputstream. This inputstream can be used to read bytes to the remote side. However, this is also a blocking call, which can block indefinitly at any point in time, since a GSM network is hostile per definition.

Is it possible by any call to unblock this .read() call (by SocketConnection.close()?) or is there a read call with timeout?

What puzzles me is that a Java ME implementation was used in a hostile environment with no certainties whatsoever without giving a programmer the means to do something about it.

Could you advise me how such things are to be tackled?