The client is pretty safe - that will keep running, you just need to reestablish the connection.
To detect the lost of connection you can use a "heartbeat" or figure if a regular connection you're making is not working (like updating some table with server's data).
The server - you need to wrap the servers application in a windows service.
YAJSW[
^] is pretty good, simple and works great.