Hey,
I want to connect my client via socket to a server. If I don't start
the server (to test my error-handlung) the client crashes because of
an uncaught timeout exception.
The socket creation is in a try-catch block, but the timeout-exception
is not caught.
try {
InetAddress serverAddr =
InetAddress.getByName(SERVERIP);
Log.i(LOG_TAG, "Connecting..");
clientSocket = new Socket(serverAddr, PORT); ->
Timeoutexception
Log.i(LOG_TAG, "Connection done!");
// open OutputStream and InputStream
Log.i(LOG_TAG, "Open data streams");
out = new
DataOutputStream(clientSocket.getOutputStream());
in = new
DataInputStream(clientSocket.getInputStream());
Log.i(LOG_TAG, "Set client keep-alive");
clientSocket.setKeepAlive(true);
} catch (UnknownHostException e) {
Log.v(LOG_TAG, e.toString());
statusCode = Protocol.UNKNOWN_HOST;
}catch (SocketException e) {
Log.v(LOG_TAG, e.toString());
statusCode = Protocol.SOCKET_ERROR;
}catch (IOException e) {
Log.v(LOG_TAG, e.toString());
statusCode = Protocol.IO_ERROR;
}catch (Exception e) {
Log.v(LOG_TAG, e.toString());
statusCode = Protocol.SOCKET_ERROR;
}
Has anybody experienced the same problem?
Thanks in advance and regards,
Lara
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en