Frustration! You have to start all over again! Well there is a way to actually prevent this from happening in the first place by using the SSH server keep-alive setting.
If you're using PuTTY, in the connection preferences you can set a value to send a 'heartbeat' to the server, 60 is a good value to use.
If you're connecting from a Unix based environment simply edit your ~/.ssh/config file (or create one if it doesn't exist) and set it up like this...
Instead of * you can specify an actual server hostname but it makes sense to have it configured for all servers with a wildcard.