Connection reset simply means that a TCP RST was received.
This happens when your peer receives data that it can't process,
and there can be various reasons for that. The simplest is when you close
the socket, and then write more data on the output stream. By closing the
socket, you told your peer that you are done talking, and it can forget
about your connection. When you send more data on that stream anyway, the peer rejects it with an RST to let you know it isn't listening.
In other cases, an intervening firewall or even the remote host itself
might "forget" about your TCP connection. This could happen if you don't
send any data for a long time (2 hours is a common time-out), or because
the peer was rebooted and lost its information about active connections.
Sending data on one of these defunct connections will cause a RST too.