I have a simple client-server app on android. the android service communicates with the server via tcp sockets. the service sends a simple String to server which works. the server processes the string and sends back an object to the android service. the object implements the serializable interface. the object “leaves” the server successfully but at the point where the android service receives the object (socket.readObject()) I get to following exception:
java.net.SocketException: Bad socket
I’ve never seen this. What does that mean?
Edit:
Method where exception gets thrown:
private static void startContextListener(){
new Thread(){
public void run(){
try{
while(contextsocket != null && !contextsocket.isClosed() && inContext.readObject() != null){
kontext = (Kontext) inContext.readObject();
}
}
catch(Exception e){
Log.e(TAG, "startContextListener(): " + e.toString());
}
}
}.start();
}
This is usually a result of
read(2)on invalid socket descriptor ([EBADF] fildes is not a valid file or socket descriptor open for reading) so it looks that some layer of the app is closing the socket. Can you post more code to demonstrate how you work with the socket?