winsane: Handle connection loss by closing the socket
winsane: Provide Socket IsConnected function to check connectivity
winsane: Fixed usage of invalid array index variable