Networking Migration Reference
Step-by-step guides for moving between networking APIs. It starts with a decision tree for whether to migrate at all, then covers three migration paths with before/after code, mapping tables, and the benefits of each.
When to Use This Reference
Use this reference when you need to:
- Decide whether to migrate or stay with your current API
- Migrate from BSD sockets,
CFSocket, orNSStreamtoNWConnection - Replace
SCNetworkReachabilitywithNWPathMonitor - Upgrade from
NWConnectiontoNetworkConnection(iOS 26+) - Replace a URLSession stream task with
NetworkConnection - Understand the mapping between old and new APIs
Example Prompts
Questions you can ask your assistant that will draw from this reference:
- "How do I migrate from BSD sockets to
NWConnection?" - "What's the equivalent of
NWConnection'sstateUpdateHandlerinNetworkConnection?" - "How do I replace completion handlers with async/await for networking?"
- "Should I migrate from a URLSession stream task to
NetworkConnection?" - "What are the benefits of moving to
NetworkConnectionon iOS 26?" - "How do I replace
[weak self]patterns when migrating to async/await?" - "Is
NWConnectiondeprecated?"
What's Covered
- Do I need to migrate? – A decision tree by current API: URLSession for HTTP stays, BSD sockets and
CFSocket/NSStreammove toNWConnection,SCNetworkReachabilitymoves toNWPathMonitor, and workingNWConnectioncode can stay because it isn't deprecated - BSD sockets to NWConnection – Mapping table for
socket/connect/send/recv/bind/listen/acceptand theirNWConnectionequivalents, with complete before/after code - NWConnection to NetworkConnection – Completion handlers to async/await,
stateUpdateHandlerto theonStateUpdateclosure, manual JSON to the built-inCoderprotocol, custom framers to built-in TLV - URLSession stream task to NetworkConnection – When to migrate (UDP, custom protocols, low-level control) and when to stay (HTTP, WebSocket, caching)
- Line count reductions – 20 to 10 lines and 30 to 15 lines in the examples
- Memory management changes – Why async/await removes the need for
[weak self]
Documentation Scope
This page documents the networking-migration skill (in the axiom-networking suite), the migration guides your assistant uses when helping you move between networking API generations. The skill contains complete before/after examples for each migration path.
Related
- networking – Modern networking patterns and architecture decisions
- networking-legacy –
NWConnectionpatterns for apps that support iOS 12–18 - network-framework-ref – Complete Network.framework API reference
- networking-diag – Troubleshooting connection failures
Resources
WWDC: 2018-715, 2025-250
Docs: /network, /network/nwconnection