Thank you, Chris_g1, for the response but I'm sorry to say that none of these options really addressed my questions. Perhaps I didn't explain my problem clearly...
The problem is intermittent, and is always solved by rebooting my Mac.
I tend to leave my Mac running for days, but put it to sleep (or let it go to sleep) when I'm not using it. I'm not fussy about quitting apps before the Mac goes into sleep mode, so sometimes the radio app and a few Safari windows (for example) might be left open. I also use MS Office for Mac and sometimes Adobe programs. I get the impression (but could be wrong) that this problem occurs after the Mac awakes with one or more of these apps running - but have no idea what could be causing the fault. I can't reproduce the fault deliberately. Mostly when I wake up the Mac everything works just fine - but sometimes I get this annoying problem. I'd love to know what is causing it, so that I could prevent it from happening. Alternatively I feel that I should be able to invoke some kind of internet connection reset without having to resort to a complete reboot. (I have tried turning off the internet connection or unplugging it and then reconnecting - but this simply restores the same faulty situation.)
A symptom of the problem is that I can't connect to the Apple ID server. I get the error message "There was an error connecting to the Apple ID server". Presumably this is why I can't connect to the App Store? Remember that apparently all other internet connections seem to work well, so this is not a simple connectivity fault. Furthermore the problem is always solved by a reboot. So what is the reboot doing to restore this connectivity to the Apple ID server?
Incidentally I use Kaspersky Internet Security. (I have tried turning it off - no difference to this problem). After I have rebooted having had this problem I usually get a message from Kaspersky saying that it hadn't connected properly last time. I get the impression that connectivity to Kaspersky's server had been lost in a similar way to that to the Apple ID server.
These ID servers seem to require some special connectivity requirement that my machine is losing when it goes to sleep sometimes. So what is this special requirement - and how can I restore it without doing a reboot?