Socket listener for chat client
I'm not sure about your first question - I've never programmed on a mobile device where power was an issue.

In answer to your second question, one of the options for sockets that is contained in the specification for TCP/IP is SO_KEEPALIVE. When this is set to true, the internal socket mechanism takes care of keeping the connection alive so that you don't have to worry about heart beats or anything like that. The Socket class has accessors for SO_KEEPALIVE.

Also, you need to seriously refactor this code and extract out the two meaningful parts into functions (one does the connecting, one the R/W). As it is the code is too long and complicated to be able to easily follow the logic.