The solution is very simple:
String networkAvailable = System.getProperty("com.nokia.mid.networkavailability");
// Warn the user that the network is not available and off-line mode is used
// Network available => we could work as normal.
The trick here works on the Nokia S60 platform FP3, or later. I have not found out a solution on a Nokia S40 phone. Does anyone know?