Although the existing answers provide a more-or-less accurate description on how this ongoing connection looks like - they describe the feature using terms that are generic (IP, API, TCP+keep-alive) and so on - that may be true - but miss the whole "Apple" face of the thing. These answers could explain both Android and Windows and actually any computing platform maintaining long-term responsive connections.
The important addition I want to add here - is that Apple's "Base OS" - the part shared between MacOS iOS tvOS, watchOS and so on - contains several sub-systems and APIs that allow such behavior practically "for free" to any software developer, provided they use the "recommended" OS subsystems, and not mere generic networking APIs (such as posix etc.)
The ability to maintain long-term responsive connection is not required just by notififaction-based services (like "FindMy" and others - but also for all remote-media services - FaceTime, iTunes, Maps (Navigation) and in reality all their competitors too (Zoom, Viber, Slack, and friends).
One important feature the OP did NOT mention - the ability to survive and renew connection immediately when switching networks, network-stacks and when using multiple networking-stacks and facilities concurrently - is important too. an iPhone can switch from Cellular to WiFi, to Bluetooth and even use all 3 together dozens of times within a single call.
The important mechanisms to learn are:
- The SystemConfiguration framework (for "Reachability" and non-polling ability to maintain a connection)
- CFNetwork Framework - the Core Foundation framework implementing most of the low and high level interfaces to network services- where all access via "proxy" or "firewall" or long-term-connection maintenance is implemented
- NSURLSession - the higher level Swift/Obj-C APIs allowing app developers maintain such connections.
I had to use all three when I developers Audio/Video-Conferencing software, security agents, remote-database-management tools and many others. I always marveled how easy and efficient Apple-provided APIs were in comparison with solutions I built for other platforms.
Just a tiny example: When you "tell the OS" you want to keep connection to specific Server - and be notified on changes in its "Reachability", the OS does this for you - but NOT within your own process. It is an OS service. So... your app can be killed, and be re-launched immediately when connection is re-established. Also - if 3 processes need maintain connection to some domain or service - OS only tracks that domain/service ONCE for all registered "listeners". which also improves efficiency.
So - When you plug Ethernet cable in or out - OS doesn't need to "poll" on the thing - it maintains the interrupt-based hardware anyway. It can be done much more efficiently! same for when you lose Cellular connection.
Last - I recommend on learning these 3 Apple frameworks, and learn how its done on this platform.
A good start can be watching this video from Apple WWDC 2015 - Introducing Network.framework: A modern alternative to Sockets