axiom-networking-migration
Installation
SKILL.md
Network Framework Migration Guides
Migration 1: From BSD Sockets to NWConnection
Migration mapping
| BSD Sockets | NWConnection | Notes |
|---|---|---|
socket() + connect() |
NWConnection(host:port:using:) + start() |
Non-blocking by default |
send() / sendto() |
connection.send(content:completion:) |
Async, returns immediately |
recv() / recvfrom() |
connection.receive(minimumIncompleteLength:maximumLength:completion:) |
Async, returns immediately |
bind() + listen() |
NWListener(using:on:) |
Automatic port binding |
accept() |
listener.newConnectionHandler |
Callback for each connection |
getaddrinfo() |
Let NWConnection handle DNS | Smart resolution with racing |
SCNetworkReachability |
connection.stateUpdateHandler waiting state |
No race conditions |
setsockopt() |
NWParameters configuration |
Type-safe options |