If you want to detect the actual connection state, you may use the clientListener, check this:
As both cores on esp32 shares the memory, to use both cores on esp32 you need to apply semaphores, to control the access to the same resource (or many resources) by multiple process.