[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6R1S84JR76C298P0HGYNJMT":3,"skill-same:01M6R1S84JR76C298P0HGYNJMT":66},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":33,"linkOnly":34,"markdownContent":35,"markdownBody":36,"frontMatter":37,"refName":42,"commitSha":43,"skillDirectory":44,"forksCount":45,"repositoryHtmlUrl":46,"repositoryHomepageUrl":47,"ownerHtmlUrl":48,"ownerBlogUrl":49,"ownerDescription":50,"updatedAt":51,"install":52,"resources":65},"01M6R1S84JR76C298P0HGYNJMT","axiom-network-framework-ref",null,"Reference — Comprehensive Network.framework guide covering NetworkConnection (iOS 26+), NWConnection (iOS 12-25), TLV framing, Coder protocol, NetworkListener, NetworkBrowser, Wi-Fi Aware discovery, and migration strategies","VRIL-LABS\u002Fskill-jam","VRIL-LABS","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F272046472?v=4","01M6QR9PNWM28WZYJJASER1RG2","𝗩𝗥𝗜𝗟 𝗟𝗔𝗕𝗦","01M6QR9PT6Q6JDCQ97EQBDX6E4",2,"MIT","https:\u002F\u002Fgithub.com\u002FVRIL-LABS\u002Fskill-jam\u002Fblob\u002Fmain\u002Fskills\u002Fother\u002Fcharleswiltgen-axiom-axiom-network-framework-ref-1.0.2\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32],"framework","network","axiom network framework ref","axiom","protocol","ios","discovery","coder","guide","migration","reference","strategies","2025","fi","2026-11-10 10:12:30",false,"---\nname: axiom-network-framework-ref\ndescription: Reference — Comprehensive Network.framework guide covering NetworkConnection (iOS 26+), NWConnection (iOS 12-25), TLV framing, Coder protocol, NetworkListener, NetworkBrowser, Wi-Fi Aware discovery, and migration strategies\nlicense: MIT\ncompatibility: iOS 12+ (NWConnection), iOS 26+ (NetworkConnection)\nmetadata:\n  version: \"1.0.0\"\n  last-updated: \"2025-12-02\"\n---\n\n# Network.framework API Reference\n\n## Overview\n\nNetwork.framework is Apple's modern networking API that replaces Berkeley sockets, providing smart connection establishment, user-space networking, built-in TLS support, and seamless mobility. Introduced in iOS 12 (2018) with NWConnection and evolved in iOS 26 (2025) with NetworkConnection for structured concurrency.\n\n#### Evolution timeline\n- **2018 (iOS 12)** NWConnection with completion handlers, deprecates CFSocket\u002FNSStream\u002FSCNetworkReachability\n- **2019 (iOS 13)** User-space networking (30% CPU reduction), TLS 1.3 default\n- **2025 (iOS 26)** NetworkConnection with async\u002Fawait, TLV framing built-in, Coder protocol, Wi-Fi Aware discovery\n\n#### Key capabilities\n- **Smart connection establishment** Happy Eyeballs (IPv4\u002FIPv6 racing), proxy evaluation (PAC), VPN detection, WiFi Assist fallback\n- **User-space networking** ~30% lower CPU usage vs sockets, memory-mapped regions, reduced context switches\n- **Built-in security** TLS 1.3 by default, DTLS for UDP, certificate pinning support\n- **Mobility** Automatic network transition handling (WiFi ↔ cellular), viability notifications, Multipath TCP\n- **Performance** ECN (Explicit Congestion Notification), service class marking, TCP Fast Open, UDP batching\n\n#### When to use vs URLSession\n- **URLSession** HTTP, HTTPS, WebSocket, simple TCP\u002FTLS streams → Use URLSession (optimized for these)\n- **Network.framework** UDP, custom protocols, low-level control, peer-to-peer, gaming, streaming → Use Network.framework\n\n#### Related Skills\n- Use `axiom-networking` for anti-patterns, common patterns, pressure scenarios\n- Use `axiom-networking-diag` for systematic troubleshooting of connection failures\n\n---\n\n## When to Use This Skill\n\nUse this skill when:\n- **Planning migration** from BSD sockets, CFSocket, NSStream, or SCNetworkReachability\n- **Understanding API differences** between NWConnection (iOS 12-25) and NetworkConnection (iOS 26+)\n- **Implementing all 12 WWDC 2025 examples** (TLS connection, TLV framing, Coder protocol, NetworkListener, Wi-Fi Aware)\n- **Choosing protocols** (TCP, UDP, TLS, QUIC) for your use case\n- **Peer-to-peer discovery** setup with NetworkBrowser and Wi-Fi Aware\n- **Optimizing performance** with user-space networking, batching, pacing\n- **Migrating** from completion handlers to async\u002Fawait (NWConnection → NetworkConnection)\n\n---\n\n## API Evolution\n\n### Timeline\n\n| Year | iOS Version | Key Features |\n|------|-------------|--------------|\n| 2018 | iOS 12 | NWConnection, NWListener, NWBrowser introduced |\n| 2019 | iOS 13 | User-space networking (30% CPU reduction), TLS 1.3 default |\n| 2021 | iOS 15 | WebSocket support in URLSession |\n| 2025 | iOS 26 | NetworkConnection (async\u002Fawait), TLV framing, Coder protocol, Wi-Fi Aware |\n\n### NWConnection (iOS 12-25) vs NetworkConnection (iOS 26+)\n\n| Feature | NWConnection (iOS 12-25) | NetworkConnection (iOS 26+) |\n|---------|-------------------------|----------------------------|\n| **Async model** | Completion handlers | async\u002Fawait structured concurrency |\n| **State updates** | `stateUpdateHandler` callback | `states` AsyncSequence |\n| **Send** | `send(content:completion:)` callback | `try await send(content)` suspending |\n| **Receive** | `receive(minimumIncompleteLength:maximumLength:completion:)` | `try await receive(exactly:)` suspending |\n| **Framing** | Manual or custom NWFramer | TLV built-in (`TLV { TLS() }`) |\n| **Codable** | Manual JSON encode\u002Fdecode | Coder protocol (`Coder(MyType.self, using: .json)`) |\n| **Memory** | Requires `[weak self]` in all closures | No `[weak self]` needed (Task cancellation automatic) |\n| **Error handling** | Check error in completion | `throws` with natural propagation |\n| **State machine** | Callbacks on state changes | `for await state in connection.states` |\n| **Discovery** | NWBrowser (Bonjour only) | NetworkBrowser (Bonjour + Wi-Fi Aware) |\n\n#### Recommendation\n- New apps targeting iOS 26+: Use NetworkConnection (cleaner, safer)\n- Apps supporting iOS 12-25: Use NWConnection (backward compatible)\n- Migration: Both APIs coexist, migrate incrementally\n\n---\n\n## NetworkConnection (iOS 26+) Complete Reference\n\n### 4.1 Creating Connections\n\nNetworkConnection uses declarative protocol stack composition.\n\n#### Example 1: Basic TLS Connection (WWDC 4:04)\n\n```swift\nimport Network\n\n\u002F\u002F Basic connection with TLS (TCP and IP inferred)\nlet connection = NetworkConnection(\n    to: .hostPort(host: \"www.example.com\", port: 1029)\n) {\n    TLS()\n}\n\n\u002F\u002F Send and receive with async\u002Fawait\npublic func sendAndReceiveWithTLS() async throws {\n    let outgoingData = Data(\"Hello, world!\".utf8)\n    try await connection.send(outgoingData)\n\n    let incomingData = try await connection.receive(exactly: 98).content\n    print(\"Received data: \\(incomingData)\")\n}\n```\n\n#### Key points\n- `TLS()` infers `TCP()` and `IP()` automatically\n- No explicit connection.start() needed (happens on first send\u002Freceive)\n- Async\u002Fawait eliminates callback nesting\n\n#### Example 2: Custom IP Options (WWDC 4:41)\n\n```swift\n\u002F\u002F Customize IP fragmentation\nlet connection = NetworkConnection(\n    to: .hostPort(host: \"www.example.com\", port: 1029)\n) {\n    TLS {\n        TCP {\n            IP()\n                .fragmentationEnabled(false) \u002F\u002F Disable IP fragmentation\n        }\n    }\n}\n```\n\n#### When to customize IP\n- `.fragmentationEnabled(false)` — For protocols that handle fragmentation themselves (QUIC)\n- `.ipVersion(.v6)` — Force IPv6 only (testing)\n\n#### Example 3: Custom Parameters (WWDC 5:07)\n\n```swift\n\u002F\u002F Constrained paths (low data mode) + custom IP\nlet connection = NetworkConnection(\n    to: .hostPort(host: \"www.example.com\", port: 1029),\n    using: .parameters {\n        TLS {\n            TCP {\n                IP()\n                    .fragmentationEnabled(false)\n            }\n        }\n    }\n    .constrainedPathsProhibited(true) \u002F\u002F Don't use cellular in low data mode\n)\n```\n\n#### Common parameters\n- `.constrainedPathsProhibited(true)` — Respect low data mode\n- `.expensivePathsProhibited(true)` — Don't use cellular\u002Fhotspot\n- `.multipathServiceType(.handover)` — Enable Multipath TCP\n\n#### Endpoint Types\n\n```swift\n\u002F\u002F Host + Port\n.hostPort(host: \"example.com\", port: 443)\n\n\u002F\u002F Service (Bonjour)\n.service(name: \"MyPrinter\", type: \"_ipp._tcp\", domain: \"local.\", interface: nil)\n\n\u002F\u002F Unix domain socket\n.unix(path: \"\u002Ftmp\u002Fmy.sock\")\n```\n\n#### Protocol Stack Composition\n\n```swift\n\u002F\u002F TLS over TCP (most common)\nTLS()\n\n\u002F\u002F QUIC (TLS + UDP, multiplexed streams)\nQUIC()\n\n\u002F\u002F UDP (datagrams)\nUDP()\n\n\u002F\u002F TCP (stream, no encryption)\nTCP()\n\n\u002F\u002F WebSocket over TLS\nWebSocket {\n    TLS()\n}\n\n\u002F\u002F Custom framing\nTLV {\n    TLS()\n}\n```\n\n---\n\n### 4.2 State Machine\n\nNetworkConnection transitions through these states:\n\n```\nsetup\n  ↓\npreparing (DNS, TCP handshake, TLS handshake)\n  ↓\n┌─ waiting (no network, retrying)\n│    ↓\n└→ ready (can send\u002Freceive)\n     ↓\n  failed (error) or cancelled\n```\n\n#### Monitoring States\n\n```swift\n\u002F\u002F Option 1: Async sequence (monitor in background)\nTask {\n    for await state in connection.states {\n        switch state {\n        case .preparing:\n            print(\"Connecting...\")\n        case .waiting(let error):\n            print(\"Waiting for network: \\(error)\")\n        case .ready:\n            print(\"Connected!\")\n        case .failed(let error):\n            print(\"Failed: \\(error)\")\n        case .cancelled:\n            print(\"Cancelled\")\n        @unknown default:\n            break\n        }\n    }\n}\n```\n\n#### Key states\n- **.preparing** DNS lookup, TCP SYN, TLS handshake\n- **.waiting** No network available, framework retries automatically\n- **.ready** Connection established, can send\u002Freceive\n- **.failed** Unrecoverable error (server refused, TLS failed, timeout)\n- **.cancelled** Task cancelled or connection.cancel() called\n\n---\n\n### 4.3 Send\u002FReceive Patterns\n\n#### Send: Basic\n\n```swift\nlet data = Data(\"Hello\".utf8)\ntry await connection.send(data)\n```\n\n#### Receive: Exact Byte Count (WWDC 7:30)\n\n```swift\n\u002F\u002F Receive exactly 98 bytes\nlet incomingData = try await connection.receive(exactly: 98).content\nprint(\"Received \\(incomingData.count) bytes\")\n```\n\n#### Receive: Variable Length (WWDC 8:29)\n\n```swift\n\u002F\u002F Read UInt32 length prefix, then read that many bytes\nlet remaining32 = try await connection.receive(as: UInt32.self).content\nguard var remaining = Int(exactly: remaining32) else { throw MyError.invalidLength }\n\nwhile remaining > 0 {\n    let chunk = try await connection.receive(atLeast: 1, atMost: remaining).content\n    remaining -= chunk.count\n    \u002F\u002F Process chunk...\n}\n```\n\n#### receive() variants\n- `receive(exactly: n)` — Wait for exactly n bytes\n- `receive(atLeast: min, atMost: max)` — Get between min and max bytes\n- `receive(as: UInt32.self)` — Read fixed-size type (network byte order)\n\n---\n\n### 4.4 TLV Framing (iOS 26+)\n\n**TLV (Type-Length-Value)** solves message boundary problem on stream protocols (TCP\u002FTLS).\n\n#### Format\n- Type: UInt32 (message identifier)\n- Length: UInt32 (message size, automatic)\n- Value: Message bytes\n\n#### Example: GameMessage with TLV (WWDC 11:06, 11:24, 11:53)\n\n```swift\nimport Network\n\n\u002F\u002F Define message types\nenum GameMessage: Int {\n    case selectedCharacter = 0\n    case move = 1\n}\n\nstruct GameCharacter: Codable {\n    let character: String\n}\n\nstruct GameMove: Codable {\n    let row: Int\n    let column: Int\n}\n\n\u002F\u002F Connection with TLV framing\nlet connection = NetworkConnection(\n    to: .hostPort(host: \"www.example.com\", port: 1029)\n) {\n    TLV {\n        TLS()\n    }\n}\n\n\u002F\u002F Send typed message\npublic func sendWithTLV() async throws {\n    let characterData = try JSONEncoder().encode(GameCharacter(character: \"?\"))\n    try await connection.send(characterData, type: GameMessage.selectedCharacter.rawValue)\n}\n\n\u002F\u002F Receive typed message\npublic func receiveWithTLV() async throws {\n    let (incomingData, metadata) = try await connection.receive()\n\n    switch GameMessage(rawValue: metadata.type) {\n    case .selectedCharacter:\n        let character = try JSONDecoder().decode(GameCharacter.self, from: incomingData)\n        print(\"Character selected: \\(character)\")\n    case .move:\n        let move = try JSONDecoder().decode(GameMove.self, from: incomingData)\n        print(\"Move: row=\\(move.row), column=\\(move.column)\")\n    case .none:\n        print(\"Unknown message type: \\(metadata.type)\")\n    }\n}\n```\n\n#### Benefits\n- Message boundaries preserved (send 3 messages → receive exactly 3)\n- Type-safe message handling (enum-based routing)\n- Minimal overhead (8 bytes per message: type + length)\n\n#### When to use\n- Mixed message types (chat + presence + typing)\n- Existing protocols using TLV\n- Need message boundaries without heavy framing\n\n---\n\n### 4.5 Coder Protocol (iOS 26+)\n\n**Coder** eliminates manual JSON encoding\u002Fdecoding boilerplate.\n\n#### Example: GameMessage with Coder (WWDC 12:50, 13:13, 13:53)\n\n```swift\nimport Network\n\n\u002F\u002F Define message types as Codable enum\nenum GameMessage: Codable {\n    case selectedCharacter(String)\n    case move(row: Int, column: Int)\n}\n\n\u002F\u002F Connection with Coder\nlet connection = NetworkConnection(\n    to: .hostPort(host: \"www.example.com\", port: 1029)\n) {\n    Coder(GameMessage.self, using: .json) {\n        TLS()\n    }\n}\n\n\u002F\u002F Send Codable directly (no encoding needed!)\npublic func sendWithCoder() async throws {\n    let selectedCharacter: GameMessage = .selectedCharacter(\"?\")\n    try await connection.send(selectedCharacter)\n}\n\n\u002F\u002F Receive Codable directly (no decoding needed!)\npublic func receiveWithCoder() async throws {\n    let gameMessage = try await connection.receive().content \u002F\u002F Returns GameMessage!\n\n    switch gameMessage {\n    case .selectedCharacter(let character):\n        print(\"Character selected: \\(character)\")\n    case .move(let row, let column):\n        print(\"Move: (\\(row), \\(column))\")\n    }\n}\n```\n\n#### Supported formats\n- `.json` — JSON encoding (human-readable, widely compatible)\n- `.propertyList` — Property list (faster, smaller)\n\n#### Benefits\n- No JSON boilerplate (~50 lines → ~10 lines)\n- Type-safe (compiler catches message structure changes)\n- Automatic framing (handles message boundaries)\n\n#### When to use\n- App-to-app communication (you control both ends)\n- Prototyping (fastest time to working code)\n- Type-safe protocols\n\n#### When NOT to use\n- Interoperating with non-Swift servers\n- Need custom wire format\n- Performance-critical (prefer manual encoding for control)\n\n---\n\n### 4.6 NetworkListener (iOS 26+)\n\nListen for incoming connections with automatic subtask management.\n\n#### Example: Listening for Connections (WWDC 15:16)\n\n```swift\nimport Network\n\n\u002F\u002F Listener with Coder protocol\npublic func listenForIncomingConnections() async throws {\n    try await NetworkListener {\n        Coder(GameMessage.self, using: .json) {\n            TLS()\n        }\n    }.run { connection in\n        \u002F\u002F Each connection gets its own subtask\n        for try await (gameMessage, _) in connection.messages {\n            switch gameMessage {\n            case .selectedCharacter(let character):\n                print(\"Player chose: \\(character)\")\n            case .move(let row, let column):\n                print(\"Player moved: (\\(row), \\(column))\")\n            }\n        }\n    }\n}\n```\n\n#### Key features\n- Automatic subtask per connection (no manual Task management)\n- Structured concurrency (all subtasks cancelled when listener exits)\n- `connection.messages` async sequence for receiving\n\n#### Listener configuration\n\n```swift\n\u002F\u002F Specify port\nNetworkListener(port: 1029) { TLS() }\n\n\u002F\u002F Let system choose port\nNetworkListener { TLS() }\n\n\u002F\u002F Bonjour advertising\nNetworkListener(service: .init(name: \"MyApp\", type: \"_myapp._tcp\")) { TLS() }\n```\n\n---\n\n### 4.7 NetworkBrowser & Wi-Fi Aware (iOS 26+)\n\nDiscover endpoints on local network or nearby devices.\n\n#### Example: Wi-Fi Aware Discovery (WWDC 17:39)\n\n```swift\nimport Network\nimport WiFiAware\n\n\u002F\u002F Browse for nearby paired Wi-Fi Aware devices\npublic func findNearbyDevice() async throws {\n    let endpoint = try await NetworkBrowser(\n        for: .wifiAware(.connecting(to: .allPairedDevices, from: .ticTacToeService))\n    ).run { endpoints in\n        .finish(endpoints.first!) \u002F\u002F Use first discovered device\n    }\n\n    \u002F\u002F Make connection to the discovered endpoint\n    let connection = NetworkConnection(to: endpoint) {\n        Coder(GameMessage.self, using: .json) {\n            TLS()\n        }\n    }\n}\n```\n\n#### Wi-Fi Aware features\n- Peer-to-peer without infrastructure (no WiFi router needed)\n- Automatic discovery of paired devices\n- Low latency, axiom-high throughput\n- iOS 26+ only\n\n#### Browse descriptors\n\n```swift\n\u002F\u002F Bonjour\n.bonjour(type: \"_http._tcp\", domain: \"local\")\n\n\u002F\u002F Wi-Fi Aware (all paired devices)\n.wifiAware(.connecting(to: .allPairedDevices, from: .myService))\n\n\u002F\u002F Wi-Fi Aware (specific device)\n.wifiAware(.connecting(to: .pairedDevice(identifier: deviceID), from: .myService))\n```\n\n---\n\n## NWConnection (iOS 12-25) Complete Reference\n\n### 5.1 Creating Connections\n\nNWConnection uses completion handlers (pre-async\u002Fawait).\n\n#### Basic TLS Connection (WWDC 2018 lines 133-166)\n\n```swift\nimport Network\n\n\u002F\u002F Create connection\nlet connection = NWConnection(\n    host: NWEndpoint.Host(\"mail.example.com\"),\n    port: NWEndpoint.Port(integerLiteral: 993),\n    using: .tls \u002F\u002F TCP inferred\n)\n\n\u002F\u002F Handle connection state changes\nconnection.stateUpdateHandler = { [weak self] state in\n    switch state {\n    case .ready:\n        print(\"Connection established\")\n        self?.sendData()\n\n    case .waiting(let error):\n        print(\"Waiting for network: \\(error)\")\n        \u002F\u002F Show \"Waiting...\" UI, don't fail immediately\n\n    case .failed(let error):\n        print(\"Connection failed: \\(error)\")\n\n    case .cancelled:\n        print(\"Connection cancelled\")\n\n    default:\n        break\n    }\n}\n\n\u002F\u002F Start connection\nconnection.start(queue: .main)\n```\n\n**Critical** Always use `[weak self]` in stateUpdateHandler to prevent retain cycles.\n\n#### Custom Parameters\n\n```swift\n\u002F\u002F Create custom parameters\nlet parameters = NWParameters.tls\n\n\u002F\u002F Prohibit expensive networks\nparameters.prohibitExpensivePaths = true \u002F\u002F Don't use cellular\u002Fhotspot\n\n\u002F\u002F Prohibit constrained networks\nparameters.prohibitConstrainedPaths = true \u002F\u002F Respect low data mode\n\n\u002F\u002F Require IPv6\nparameters.requiredInterfaceType = .wifi\nparameters.ipOptions.version = .v6\n\nlet connection = NWConnection(host: \"example.com\", port: 443, using: parameters)\n```\n\n---\n\n### 5.2 State Handling\n\nNWConnection state machine (same as NetworkConnection):\n\n```\nsetup → preparing → waiting\u002Fready → failed\u002Fcancelled\n```\n\n#### State handling best practices\n\n```swift\nconnection.stateUpdateHandler = { [weak self] state in\n    guard let self = self else { return }\n\n    switch state {\n    case .preparing:\n        \u002F\u002F DNS lookup, TCP SYN, TLS handshake in progress\n        self.updateUI(.connecting)\n\n    case .waiting(let error):\n        \u002F\u002F Network unavailable or blocked\n        \u002F\u002F DON'T fail immediately, framework retries automatically\n        print(\"Waiting: \\(error.localizedDescription)\")\n        self.updateUI(.waiting)\n\n    case .ready:\n        \u002F\u002F Connection established, can send\u002Freceive\n        self.updateUI(.connected)\n        self.startSending()\n\n    case .failed(let error):\n        \u002F\u002F Unrecoverable error after all retry attempts\n        print(\"Failed: \\(error.localizedDescription)\")\n        self.updateUI(.failed)\n\n    case .cancelled:\n        \u002F\u002F connection.cancel() called\n        self.updateUI(.disconnected)\n\n    default:\n        break\n    }\n}\n```\n\n---\n\n### 5.3 Send\u002FReceive with Callbacks\n\n#### Send with Pacing (WWDC 2018 lines 320-341)\n\n```swift\n\u002F\u002F Send with contentProcessed callback for pacing\nfunc sendData() {\n    let data = Data(\"Hello, world!\".utf8)\n\n    connection.send(content: data, completion: .contentProcessed { [weak self] error in\n        if let error = error {\n            print(\"Send error: \\(error)\")\n            return\n        }\n\n        \u002F\u002F contentProcessed = network stack consumed data\n        \u002F\u002F NOW send next chunk (pacing)\n        self?.sendNextData()\n    })\n}\n```\n\n**contentProcessed callback** Invoked when network stack consumes your data (equivalent to when blocking socket call would return). Use this for pacing to avoid buffering excessive data.\n\n#### Receive with Exact Byte Count\n\n```swift\n\u002F\u002F Receive exactly 10 bytes\nconnection.receive(minimumIncompleteLength: 10, maximumLength: 10) { [weak self] (data, context, isComplete, error) in\n    if let error = error {\n        print(\"Receive error: \\(error)\")\n        return\n    }\n\n    if let data = data {\n        print(\"Received \\(data.count) bytes\")\n        \u002F\u002F Process data...\n\n        \u002F\u002F Continue receiving\n        self?.receiveMore()\n    }\n}\n```\n\n#### Receive parameters\n- `minimumIncompleteLength`: Minimum bytes before callback (1 = return any data)\n- `maximumLength`: Maximum bytes per callback\n- For \"exactly n bytes\": Set both to n\n\n---\n\n### 5.4 UDP Batching (WWDC 2018 lines 343-347)\n\n#### Batch sending for 30% CPU reduction.\n\n```swift\n\u002F\u002F UDP connection\nlet connection = NWConnection(\n    host: NWEndpoint.Host(\"game-server.example.com\"),\n    port: NWEndpoint.Port(integerLiteral: 9000),\n    using: .udp\n)\n\nconnection.start(queue: .main)\n\n\u002F\u002F Batch multiple datagrams\nfunc sendVideoFrames(_ frames: [Data]) {\n    connection.batch {\n        for frame in frames {\n            connection.send(content: frame, completion: .contentProcessed { error in\n                if let error = error {\n                    print(\"Send error: \\(error)\")\n                }\n            })\n        }\n    }\n    \u002F\u002F All sends batched into ~1 syscall\n    \u002F\u002F Result: 30% lower CPU usage vs individual sends\n}\n```\n\n**Without batch** 100 datagrams = 100 syscalls = high CPU\n**With batch** 100 datagrams = ~1 syscall = 30% lower CPU (measured with Instruments)\n\n---\n\n### 5.5 NWListener (WWDC 2018 lines 233-293)\n\nAccept incoming connections.\n\n```swift\nimport Network\n\n\u002F\u002F Create listener on port 1029\nlet listener = try NWListener(using: .tcp, on: 1029)\n\n\u002F\u002F Advertise Bonjour service\nlistener.service = NWListener.Service(name: \"MyApp\", type: \"_myapp._tcp\")\n\n\u002F\u002F Handle service registration\nlistener.serviceRegistrationUpdateHandler = { update in\n    switch update {\n    case .add(let endpoint):\n        if case .service(let name, let type, let domain, _) = endpoint {\n            print(\"Advertising: \\(name).\\(type)\\(domain)\")\n        }\n    default:\n        break\n    }\n}\n\n\u002F\u002F Handle new connections\nlistener.newConnectionHandler = { [weak self] newConnection in\n    print(\"New connection from: \\(newConnection.endpoint)\")\n\n    newConnection.stateUpdateHandler = { state in\n        if case .ready = state {\n            print(\"Client connected\")\n            self?.handleClient(newConnection)\n        }\n    }\n\n    newConnection.start(queue: .main)\n}\n\n\u002F\u002F Handle listener state\nlistener.stateUpdateHandler = { state in\n    switch state {\n    case .ready:\n        print(\"Listener ready on port \\(listener.port ?? 0)\")\n    case .failed(let error):\n        print(\"Listener failed: \\(error)\")\n    default:\n        break\n    }\n}\n\n\u002F\u002F Start listening\nlistener.start(queue: .main)\n```\n\n---\n\n### 5.6 NWBrowser (Bonjour Discovery)\n\nDiscover services on local network.\n\n```swift\nimport Network\n\n\u002F\u002F Browse for Bonjour services\nlet browser = NWBrowser(\n    for: .bonjour(type: \"_http._tcp\", domain: nil),\n    using: .tcp\n)\n\n\u002F\u002F Handle discovered services\nbrowser.browseResultsChangedHandler = { results, changes in\n    for result in results {\n        switch result.endpoint {\n        case .service(let name, let type, let domain, _):\n            print(\"Found service: \\(name).\\(type)\\(domain)\")\n\n            \u002F\u002F Connect to this service\n            let connection = NWConnection(to: result.endpoint, using: .tcp)\n            connection.start(queue: .main)\n\n        default:\n            break\n        }\n    }\n}\n\n\u002F\u002F Handle browser state\nbrowser.stateUpdateHandler = { state in\n    switch state {\n    case .ready:\n        print(\"Browser ready\")\n    case .failed(let error):\n        print(\"Browser failed: \\(error)\")\n    default:\n        break\n    }\n}\n\n\u002F\u002F Start browsing\nbrowser.start(queue: .main)\n```\n\n---\n\n## Mobility & Network Transitions\n\n### Connection Viability (WWDC 2018 lines 453-463)\n\nViability = connection can send\u002Freceive data (has valid route).\n\n```swift\nconnection.viabilityUpdateHandler = { isViable in\n    if isViable {\n        print(\"✅ Connection viable (can send\u002Freceive)\")\n    } else {\n        print(\"⚠️ Connection not viable (no route)\")\n        \u002F\u002F Don't tear down immediately, may recover\n        \u002F\u002F Show UI: \"Connection interrupted\"\n    }\n}\n```\n\n#### When viability changes\n- Walk into elevator (WiFi signal lost) → not viable\n- Walk out of elevator (WiFi returns) → viable again\n- Switch WiFi → cellular → not viable briefly → viable on cellular\n\n**Best practice** Don't tear down connection on viability loss. Framework will recover when network returns.\n\n### Better Path Available (WWDC 2018 lines 464-477)\n\nBetter path = alternative network with better characteristics.\n\n```swift\nconnection.betterPathUpdateHandler = { betterPathAvailable in\n    if betterPathAvailable {\n        print(\"? Better path available (e.g., WiFi while on cellular)\")\n        \u002F\u002F Consider migrating to new connection\n        self.migrateToNewConnection()\n    }\n}\n```\n\n#### Scenarios\n- Connected on cellular, walk into building with WiFi → better path available\n- Connected on WiFi, WiFi quality degrades, cellular available → better path available\n\n#### Migration pattern\n\n```swift\nfunc migrateToNewConnection() {\n    \u002F\u002F Create new connection\n    let newConnection = NWConnection(host: host, port: port, using: parameters)\n\n    newConnection.stateUpdateHandler = { [weak self] state in\n        if case .ready = state {\n            \u002F\u002F New connection ready, switch over\n            self?.currentConnection?.cancel()\n            self?.currentConnection = newConnection\n        }\n    }\n\n    newConnection.start(queue: .main)\n\n    \u002F\u002F Keep old connection until new one ready\n}\n```\n\n### Multipath TCP (WWDC 2018 lines 480-487)\n\nAutomatically migrate between networks without application intervention.\n\n```swift\nlet parameters = NWParameters.tcp\nparameters.multipathServiceType = .handover \u002F\u002F Seamless network transition\n\nlet connection = NWConnection(host: \"example.com\", port: 443, using: parameters)\n```\n\n#### Multipath TCP modes\n- `.handover` — Seamless handoff between networks (WiFi ↔ cellular)\n- `.interactive` — Use multiple paths simultaneously (lowest latency)\n- `.aggregate` — Use multiple paths simultaneously (highest throughput)\n\n#### Benefits\n- Automatic network transition (no viability handlers needed)\n- No connection interruption when switching networks\n- Fallback to single-path if MPTCP unavailable\n\n### NWPathMonitor (WWDC 2018 lines 489-496)\n\nMonitor network state changes (replaces SCNetworkReachability).\n\n```swift\nimport Network\n\nlet monitor = NWPathMonitor()\n\nmonitor.pathUpdateHandler = { path in\n    if path.status == .satisfied {\n        print(\"✅ Network available\")\n\n        \u002F\u002F Check interface types\n        if path.usesInterfaceType(.wifi) {\n            print(\"Using WiFi\")\n        } else if path.usesInterfaceType(.cellular) {\n            print(\"Using cellular\")\n        }\n\n        \u002F\u002F Check if expensive\n        if path.isExpensive {\n            print(\"⚠️ Expensive path (cellular\u002Fhotspot)\")\n        }\n\n    } else {\n        print(\"❌ No network\")\n    }\n}\n\nmonitor.start(queue: .main)\n```\n\n#### Use cases\n- Show \"No network\" UI when path.status == .unsatisfied\n- Disable high-bandwidth features when path.isExpensive\n- Adjust quality based on interface type\n\n#### When to use\n- Global network state monitoring\n- When \"waiting for connectivity\" isn't enough\n- Need to know available interfaces before connecting\n\n#### When NOT to use\n- Checking before connecting (use waiting state instead)\n- Per-connection monitoring (use viability handlers instead)\n\n---\n\n## Security Configuration\n\n### TLS Version\n\n```swift\n\u002F\u002F iOS 13+ requires TLS 1.2+ by default\nlet tlsOptions = NWProtocolTLS.Options()\n\n\u002F\u002F Allow TLS 1.2 and 1.3\ntlsOptions.minimumTLSProtocolVersion = .TLSv12\n\n\u002F\u002F Require TLS 1.3 only\ntlsOptions.minimumTLSProtocolVersion = .TLSv13\n\nlet parameters = NWParameters(tls: tlsOptions)\nlet connection = NWConnection(host: \"example.com\", port: 443, using: parameters)\n```\n\n### Certificate Pinning\n\n```swift\n\u002F\u002F Production-grade certificate pinning\nlet tlsOptions = NWProtocolTLS.Options()\n\nsec_protocol_options_set_verify_block(\n    tlsOptions.securityProtocolOptions,\n    { (metadata, trust, complete) in\n        \u002F\u002F Get server certificate\n        let serverCert = sec_protocol_metadata_copy_peer_public_key(metadata)\n\n        \u002F\u002F Compare with pinned certificate\n        let pinnedCertData = Data(\u002F* your pinned cert *\u002F)\n        let serverCertData = SecCertificateCopyData(serverCert) as Data\n\n        if serverCertData == pinnedCertData {\n            complete(true) \u002F\u002F Accept\n        } else {\n            complete(false) \u002F\u002F Reject (prevents MITM attacks)\n        }\n    },\n    .main\n)\n\nlet parameters = NWParameters(tls: tlsOptions)\n```\n\n### Certificate Pinning + Corporate Proxies\n\nCorporate networks often use TLS inspection proxies that present their own certificates. Strict pinning breaks these environments.\n\n**Strategy**: Pin against the public key (SPKI) rather than the full certificate, and provide a configuration escape hatch:\n\n```swift\nsec_protocol_options_set_verify_block(\n    tlsOptions.securityProtocolOptions,\n    { (metadata, trust, complete) in\n        \u002F\u002F 1. Check if system trusts the certificate chain (handles corporate CAs)\n        let secTrust = sec_trust_copy_ref(trust).takeRetainedValue()\n        SecTrustEvaluateAsyncWithError(secTrust, .main) { _, result, _ in\n            guard result else { complete(false); return }\n\n            \u002F\u002F 2. If pinning enabled, also verify public key\n            if PinningConfig.isEnabled {\n                let serverKey = SecTrustCopyKey(secTrust)\n                let matches = pinnedKeys.contains { $0 == serverKey }\n                complete(matches)\n            } else {\n                complete(true) \u002F\u002F System trust only (enterprise mode)\n            }\n        }\n    },\n    .main\n)\n```\n\n**Rules**:\n- Always validate system trust first (`SecTrustEvaluateAsyncWithError`) — this respects enterprise-installed root CAs\n- Use public key pinning over certificate pinning (survives cert rotation)\n- Provide a managed configuration (MDM profile or app config) to disable pinning in enterprise environments\n- Pin at least 2 keys (current + backup) to survive rotation\n\n### Cipher Suites\n\n```swift\nlet tlsOptions = NWProtocolTLS.Options()\n\n\u002F\u002F Specify allowed cipher suites\ntlsOptions.tlsCipherSuites = [\n    tls_ciphersuite_t(rawValue: 0x1301), \u002F\u002F TLS_AES_128_GCM_SHA256\n    tls_ciphersuite_t(rawValue: 0x1302), \u002F\u002F TLS_AES_256_GCM_SHA384\n]\n\n\u002F\u002F iOS defaults to secure modern ciphers, only customize if required\n```\n\n---\n\n## Performance Optimization\n\n### User-Space Networking (WWDC 2018 lines 409-441)\n\n**Automatic on iOS\u002FtvOS.** Network.framework moves TCP\u002FUDP stack into your app process.\n\n#### Benefits\n- ~30% lower CPU usage (measured with Instruments)\n- No kernel→userspace copy (memory-mapped regions)\n- Reduced context switches\n\n#### Legacy vs User-Space\n\n| Traditional Sockets | User-Space Networking |\n|---------------------|----------------------|\n| Packet → driver → kernel → copy → userspace | Packet → driver → memory-mapped region → userspace (no copy) |\n| 100 datagrams = 100 syscalls | 100 datagrams = ~1 syscall (with batching) |\n| ~30% higher CPU | Baseline CPU |\n\n**WWDC demo** Live UDP video streaming showed 30% CPU difference (sockets vs Network.framework).\n\n### ECN for UDP (WWDC 2018 lines 365-378)\n\nExplicit Congestion Notification for smooth UDP transmission.\n\n```swift\n\u002F\u002F Create IP metadata with ECN\nlet ipMetadata = NWProtocolIP.Metadata()\nipMetadata.ecnFlag = .congestionEncountered \u002F\u002F Or .ect0, .ect1\n\n\u002F\u002F Attach to send context\nlet context = NWConnection.ContentContext(\n    identifier: \"video_frame\",\n    metadata: [ipMetadata]\n)\n\nconnection.send(content: data, contentContext: context, completion: .contentProcessed { _ in })\n```\n\n#### ECN flags\n- `.ect0` \u002F `.ect1` — ECN-capable transport\n- `.congestionEncountered` — Congestion notification received\n\n**Benefits** Network can signal congestion without dropping packets.\n\n### Service Class (WWDC 2018 lines 379-388)\n\nMark traffic priority.\n\n```swift\n\u002F\u002F Connection-wide service class\nlet parameters = NWParameters.tcp\nparameters.serviceClass = .background \u002F\u002F Low priority\n\nlet connection = NWConnection(host: \"example.com\", port: 443, using: parameters)\n\n\u002F\u002F Per-packet service class (UDP)\nlet ipMetadata = NWProtocolIP.Metadata()\nipMetadata.serviceClass = .realTimeInteractive \u002F\u002F High priority (voice)\n\nlet context = NWConnection.ContentContext(identifier: \"voip\", metadata: [ipMetadata])\nconnection.send(content: audioData, contentContext: context, completion: .contentProcessed { _ in })\n```\n\n#### Service classes\n- `.background` — Low priority (large downloads, sync)\n- `.default` — Normal priority\n- `.responsiveData` — Interactive data (API calls)\n- `.realTimeInteractive` — Time-sensitive (voice, gaming)\n\n### TCP Fast Open (WWDC 2018 lines 389-406)\n\nSend initial data in TCP SYN packet (saves round trip).\n\n```swift\nlet parameters = NWParameters.tcp\nparameters.allowFastOpen = true\n\nlet connection = NWConnection(host: \"example.com\", port: 443, using: parameters)\n\n\u002F\u002F Send initial data BEFORE calling start()\nlet initialData = Data(\"GET \u002F HTTP\u002F1.1\\r\\n\".utf8)\nconnection.send(\n    content: initialData,\n    contentContext: .defaultMessage,\n    isComplete: false,\n    completion: .idempotent \u002F\u002F Data is safe to replay\n)\n\n\u002F\u002F Now start connection (initial data sent in SYN)\nconnection.start(queue: .main)\n```\n\n**Benefits** Reduces connection establishment time by 1 RTT.\n**Requirements** Data must be idempotent (safe to replay if SYN retransmitted).\n\n---\n\n## Migration Strategies\n\n### From BSD Sockets to NWConnection\n\n| BSD Sockets | NWConnection | Notes |\n|-------------|--------------|-------|\n| `socket() + connect()` | `NWConnection(host:port:using:) + start()` | Non-blocking by default |\n| `send() \u002F sendto()` | `connection.send(content:completion:)` | Async callback |\n| `recv() \u002F recvfrom()` | `connection.receive(min:max:completion:)` | Async callback |\n| `bind() + listen()` | `NWListener(using:on:)` | Automatic port binding |\n| `accept()` | `listener.newConnectionHandler` | Callback per connection |\n| `getaddrinfo()` | Use `NWEndpoint.Host(hostname)` | DNS automatic |\n| `SCNetworkReachability` | `connection.stateUpdateHandler` waiting state | No race conditions |\n| `setsockopt()` | `NWParameters` | Type-safe options |\n\n#### Migration example\n\n#### Before (blocking sockets)\n```c\nint sock = socket(AF_INET, SOCK_STREAM, 0);\nconnect(sock, &addr, addrlen); \u002F\u002F BLOCKS\nsend(sock, data, len, 0);\n```\n\n#### After (NWConnection)\n```swift\nlet connection = NWConnection(host: \"example.com\", port: 443, using: .tls)\nconnection.stateUpdateHandler = { state in\n    if case .ready = state {\n        connection.send(content: data, completion: .contentProcessed { _ in })\n    }\n}\nconnection.start(queue: .main)\n```\n\n### From URLSession StreamTask to NetworkConnection\n\n#### When to migrate\n- Need UDP (StreamTask only supports TCP)\n- Need custom protocols\n- Need low-level control\n\n#### When to STAY with URLSession\n- HTTP\u002FHTTPS (URLSession optimized for this)\n- WebSocket support\n- Built-in caching, cookies\n\n#### Migration example\n\n#### Before (URLSession StreamTask)\n```swift\nlet task = URLSession.shared.streamTask(withHostName: \"example.com\", port: 443)\ntask.resume()\ntask.write(Data(\"Hello\".utf8), timeout: 10) { _ in }\n```\n\n#### After (NetworkConnection iOS 26+)\n```swift\nlet connection = NetworkConnection(to: .hostPort(host: \"example.com\", port: 443)) { TLS() }\ntry await connection.send(Data(\"Hello\".utf8))\n```\n\n### From NWConnection to NetworkConnection\n\n#### Benefits of migration\n- Async\u002Fawait (no callback nesting)\n- No `[weak self]` needed\n- TLV framing built-in\n- Coder protocol for Codable types\n\n#### Migration mapping\n\n| NWConnection | NetworkConnection |\n|--------------|-------------------|\n| `connection.stateUpdateHandler = { }` | `for await state in connection.states { }` |\n| `connection.send(content:completion:)` | `try await connection.send(content)` |\n| `connection.receive(min:max:completion:)` | `try await connection.receive(exactly:)` |\n| Manual JSON | `Coder(MyType.self, using: .json)` |\n| Custom framer | `TLV { TLS() }` |\n| `[weak self]` everywhere | No `[weak self]` needed |\n\n#### Migration example\n\n#### Before (NWConnection)\n```swift\nconnection.stateUpdateHandler = { [weak self] state in\n    if case .ready = state {\n        self?.sendData()\n    }\n}\n\nfunc sendData() {\n    connection.send(content: data, completion: .contentProcessed { [weak self] error in\n        self?.receiveData()\n    })\n}\n```\n\n#### After (NetworkConnection)\n```swift\nTask {\n    for await state in connection.states {\n        if case .ready = state {\n            try await connection.send(data)\n            let received = try await connection.receive(exactly: 10).content\n        }\n    }\n}\n```\n\n---\n\n## Testing Checklist\n\nBefore shipping networking code:\n\n### Device Testing\n- [ ] Tested on real device (not just simulator)\n- [ ] Tested on multiple iOS versions (12, 15, 26)\n- [ ] Tested on iPhone and iPad (different network characteristics)\n\n### Network Conditions\n- [ ] WiFi (home network)\n- [ ] Cellular (disable WiFi)\n- [ ] Airplane Mode → WiFi (test waiting state)\n- [ ] WiFi → cellular transition (walk out of building)\n- [ ] Cellular → WiFi transition (walk into building)\n- [ ] Weak signal (basement, elevator)\n- [ ] Network Link Conditioner (100ms latency, 3% packet loss)\n\n### Network Types\n- [ ] IPv4-only network\n- [ ] IPv6-only network (some cellular carriers)\n- [ ] Dual-stack (IPv4 + IPv6)\n- [ ] Corporate VPN active\n- [ ] Personal hotspot (expensive path)\n\n### Performance\n- [ ] Connection establishment \u003C 500ms (check logs)\n- [ ] Using batch for UDP (verify with Instruments)\n- [ ] Using contentProcessed for pacing (check send timing)\n- [ ] Profiled with Instruments Network template\n- [ ] CPU usage acceptable (\u003C 10% for networking)\n- [ ] Memory stable (no leaks, check [weak self])\n\n### Error Handling\n- [ ] Handling .waiting state (show \"Waiting...\" UI)\n- [ ] Handling .failed state (specific error messages)\n- [ ] TLS handshake errors logged\n- [ ] Timeout handling (don't wait forever)\n- [ ] User-facing errors actionable (\"Check network\" not \"POSIX 61\")\n\n### iOS 26+ Features (if using NetworkConnection)\n- [ ] Using TLV framing if need message boundaries\n- [ ] Using Coder protocol if sending Codable types\n- [ ] Using NetworkListener instead of NWListener\n- [ ] Using NetworkBrowser for Wi-Fi Aware if peer-to-peer\n\n---\n\n## API Quick Reference\n\n### NetworkConnection (iOS 26+)\n\n```swift\n\u002F\u002F Create connection\nNetworkConnection(to: .hostPort(host: \"example.com\", port: 443)) { TLS() }\n\n\u002F\u002F Send\ntry await connection.send(data)\n\n\u002F\u002F Receive\ntry await connection.receive(exactly: n).content\n\n\u002F\u002F States\nfor await state in connection.states { }\n\n\u002F\u002F TLV framing\nNetworkConnection(to: endpoint) { TLV { TLS() } }\n\n\u002F\u002F Coder protocol\nNetworkConnection(to: endpoint) { Coder(MyType.self, using: .json) { TLS() } }\n\n\u002F\u002F Listener\nNetworkListener { TLS() }.run { connection in }\n\n\u002F\u002F Browser\nNetworkBrowser(for: .wifiAware(...)).run { endpoints in }\n```\n\n### NWConnection (iOS 12-25)\n\n```swift\n\u002F\u002F Create connection\nlet connection = NWConnection(host: \"example.com\", port: 443, using: .tls)\n\n\u002F\u002F State handler\nconnection.stateUpdateHandler = { [weak self] state in }\n\n\u002F\u002F Start\nconnection.start(queue: .main)\n\n\u002F\u002F Send\nconnection.send(content: data, completion: .contentProcessed { [weak self] error in })\n\n\u002F\u002F Receive\nconnection.receive(minimumIncompleteLength: min, maximumLength: max) { [weak self] data, context, isComplete, error in }\n\n\u002F\u002F Viability\nconnection.viabilityUpdateHandler = { isViable in }\n\n\u002F\u002F Better path\nconnection.betterPathUpdateHandler = { betterPathAvailable in }\n\n\u002F\u002F Cancel\nconnection.cancel()\n```\n\n### NWListener (iOS 12-25)\n\n```swift\nlet listener = try NWListener(using: .tcp, on: 1029)\nlistener.newConnectionHandler = { newConnection in }\nlistener.start(queue: .main)\n```\n\n### NWBrowser (iOS 12-25)\n\n```swift\nlet browser = NWBrowser(for: .bonjour(type: \"_http._tcp\", domain: nil), using: .tcp)\nbrowser.browseResultsChangedHandler = { results, changes in }\nbrowser.start(queue: .main)\n```\n\n### NWPathMonitor\n\n```swift\nlet monitor = NWPathMonitor()\nmonitor.pathUpdateHandler = { path in }\nmonitor.start(queue: .main)\n```\n\n---\n\n## Resources\n\n**WWDC**: 2018-715, 2025-250\n\n**Docs**: \u002Fnetwork, \u002Fnetwork\u002Fnwconnection, \u002Fnetwork\u002Fnetworkconnection\n\n**Skills**: axiom-networking, axiom-networking-diag\n\n---\n\n**Last Updated** 2025-12-02\n**Status** Production-ready reference from WWDC 2018 and WWDC 2025\n**Coverage** NWConnection (iOS 12-25), NetworkConnection (iOS 26+), all 12 WWDC 2025 code examples\n","# Network.framework API Reference\n\n## Overview\n\nNetwork.framework is Apple's modern networking API that replaces Berkeley sockets, providing smart connection establishment, user-space networking, built-in TLS support, and seamless mobility. Introduced in iOS 12 (2018) with NWConnection and evolved in iOS 26 (2025) with NetworkConnection for structured concurrency.\n\n#### Evolution timeline\n- **2018 (iOS 12)** NWConnection with completion handlers, deprecates CFSocket\u002FNSStream\u002FSCNetworkReachability\n- **2019 (iOS 13)** User-space networking (30% CPU reduction), TLS 1.3 default\n- **2025 (iOS 26)** NetworkConnection with async\u002Fawait, TLV framing built-in, Coder protocol, Wi-Fi Aware discovery\n\n#### Key capabilities\n- **Smart connection establishment** Happy Eyeballs (IPv4\u002FIPv6 racing), proxy evaluation (PAC), VPN detection, WiFi Assist fallback\n- **User-space networking** ~30% lower CPU usage vs sockets, memory-mapped regions, reduced context switches\n- **Built-in security** TLS 1.3 by default, DTLS for UDP, certificate pinning support\n- **Mobility** Automatic network transition handling (WiFi ↔ cellular), viability notifications, Multipath TCP\n- **Performance** ECN (Explicit Congestion Notification), service class marking, TCP Fast Open, UDP batching\n\n#### When to use vs URLSession\n- **URLSession** HTTP, HTTPS, WebSocket, simple TCP\u002FTLS streams → Use URLSession (optimized for these)\n- **Network.framework** UDP, custom protocols, low-level control, peer-to-peer, gaming, streaming → Use Network.framework\n\n#### Related Skills\n- Use `axiom-networking` for anti-patterns, common patterns, pressure scenarios\n- Use `axiom-networking-diag` for systematic troubleshooting of connection failures\n\n---\n\n## When to Use This Skill\n\nUse this skill when:\n- **Planning migration** from BSD sockets, CFSocket, NSStream, or SCNetworkReachability\n- **Understanding API differences** between NWConnection (iOS 12-25) and NetworkConnection (iOS 26+)\n- **Implementing all 12 WWDC 2025 examples** (TLS connection, TLV framing, Coder protocol, NetworkListener, Wi-Fi Aware)\n- **Choosing protocols** (TCP, UDP, TLS, QUIC) for your use case\n- **Peer-to-peer discovery** setup with NetworkBrowser and Wi-Fi Aware\n- **Optimizing performance** with user-space networking, batching, pacing\n- **Migrating** from completion handlers to async\u002Fawait (NWConnection → NetworkConnection)\n\n---\n\n## API Evolution\n\n### Timeline\n\n| Year | iOS Version | Key Features |\n|------|-------------|--------------|\n| 2018 | iOS 12 | NWConnection, NWListener, NWBrowser introduced |\n| 2019 | iOS 13 | User-space networking (30% CPU reduction), TLS 1.3 default |\n| 2021 | iOS 15 | WebSocket support in URLSession |\n| 2025 | iOS 26 | NetworkConnection (async\u002Fawait), TLV framing, Coder protocol, Wi-Fi Aware |\n\n### NWConnection (iOS 12-25) vs NetworkConnection (iOS 26+)\n\n| Feature | NWConnection (iOS 12-25) | NetworkConnection (iOS 26+) |\n|---------|-------------------------|----------------------------|\n| **Async model** | Completion handlers | async\u002Fawait structured concurrency |\n| **State updates** | `stateUpdateHandler` callback | `states` AsyncSequence |\n| **Send** | `send(content:completion:)` callback | `try await send(content)` suspending |\n| **Receive** | `receive(minimumIncompleteLength:maximumLength:completion:)` | `try await receive(exactly:)` suspending |\n| **Framing** | Manual or custom NWFramer | TLV built-in (`TLV { TLS() }`) |\n| **Codable** | Manual JSON encode\u002Fdecode | Coder protocol (`Coder(MyType.self, using: .json)`) |\n| **Memory** | Requires `[weak self]` in all closures | No `[weak self]` needed (Task cancellation automatic) |\n| **Error handling** | Check error in completion | `throws` with natural propagation |\n| **State machine** | Callbacks on state changes | `for await state in connection.states` |\n| **Discovery** | NWBrowser (Bonjour only) | NetworkBrowser (Bonjour + Wi-Fi Aware) |\n\n#### Recommendation\n- New apps targeting iOS 26+: Use NetworkConnection (cleaner, safer)\n- Apps supporting iOS 12-25: Use NWConnection (backward compatible)\n- Migration: Both APIs coexist, migrate incrementally\n\n---\n\n## NetworkConnection (iOS 26+) Complete Reference\n\n### 4.1 Creating Connections\n\nNetworkConnection uses declarative protocol stack composition.\n\n#### Example 1: Basic TLS Connection (WWDC 4:04)\n\n```swift\nimport Network\n\n\u002F\u002F Basic connection with TLS (TCP and IP inferred)\nlet connection = NetworkConnection(\n    to: .hostPort(host: \"www.example.com\", port: 1029)\n) {\n    TLS()\n}\n\n\u002F\u002F Send and receive with async\u002Fawait\npublic func sendAndReceiveWithTLS() async throws {\n    let outgoingData = Data(\"Hello, world!\".utf8)\n    try await connection.send(outgoingData)\n\n    let incomingData = try await connection.receive(exactly: 98).content\n    print(\"Received data: \\(incomingData)\")\n}\n```\n\n#### Key points\n- `TLS()` infers `TCP()` and `IP()` automatically\n- No explicit connection.start() needed (happens on first send\u002Freceive)\n- Async\u002Fawait eliminates callback nesting\n\n#### Example 2: Custom IP Options (WWDC 4:41)\n\n```swift\n\u002F\u002F Customize IP fragmentation\nlet connection = NetworkConnection(\n    to: .hostPort(host: \"www.example.com\", port: 1029)\n) {\n    TLS {\n        TCP {\n            IP()\n                .fragmentationEnabled(false) \u002F\u002F Disable IP fragmentation\n        }\n    }\n}\n```\n\n#### When to customize IP\n- `.fragmentationEnabled(false)` — For protocols that handle fragmentation themselves (QUIC)\n- `.ipVersion(.v6)` — Force IPv6 only (testing)\n\n#### Example 3: Custom Parameters (WWDC 5:07)\n\n```swift\n\u002F\u002F Constrained paths (low data mode) + custom IP\nlet connection = NetworkConnection(\n    to: .hostPort(host: \"www.example.com\", port: 1029),\n    using: .parameters {\n        TLS {\n            TCP {\n                IP()\n                    .fragmentationEnabled(false)\n            }\n        }\n    }\n    .constrainedPathsProhibited(true) \u002F\u002F Don't use cellular in low data mode\n)\n```\n\n#### Common parameters\n- `.constrainedPathsProhibited(true)` — Respect low data mode\n- `.expensivePathsProhibited(true)` — Don't use cellular\u002Fhotspot\n- `.multipathServiceType(.handover)` — Enable Multipath TCP\n\n#### Endpoint Types\n\n```swift\n\u002F\u002F Host + Port\n.hostPort(host: \"example.com\", port: 443)\n\n\u002F\u002F Service (Bonjour)\n.service(name: \"MyPrinter\", type: \"_ipp._tcp\", domain: \"local.\", interface: nil)\n\n\u002F\u002F Unix domain socket\n.unix(path: \"\u002Ftmp\u002Fmy.sock\")\n```\n\n#### Protocol Stack Composition\n\n```swift\n\u002F\u002F TLS over TCP (most common)\nTLS()\n\n\u002F\u002F QUIC (TLS + UDP, multiplexed streams)\nQUIC()\n\n\u002F\u002F UDP (datagrams)\nUDP()\n\n\u002F\u002F TCP (stream, no encryption)\nTCP()\n\n\u002F\u002F WebSocket over TLS\nWebSocket {\n    TLS()\n}\n\n\u002F\u002F Custom framing\nTLV {\n    TLS()\n}\n```\n\n---\n\n### 4.2 State Machine\n\nNetworkConnection transitions through these states:\n\n```\nsetup\n  ↓\npreparing (DNS, TCP handshake, TLS handshake)\n  ↓\n┌─ waiting (no network, retrying)\n│    ↓\n└→ ready (can send\u002Freceive)\n     ↓\n  failed (error) or cancelled\n```\n\n#### Monitoring States\n\n```swift\n\u002F\u002F Option 1: Async sequence (monitor in background)\nTask {\n    for await state in connection.states {\n        switch state {\n        case .preparing:\n            print(\"Connecting...\")\n        case .waiting(let error):\n            print(\"Waiting for network: \\(error)\")\n        case .ready:\n            print(\"Connected!\")\n        case .failed(let error):\n            print(\"Failed: \\(error)\")\n        case .cancelled:\n            print(\"Cancelled\")\n        @unknown default:\n            break\n        }\n    }\n}\n```\n\n#### Key states\n- **.preparing** DNS lookup, TCP SYN, TLS handshake\n- **.waiting** No network available, framework retries automatically\n- **.ready** Connection established, can send\u002Freceive\n- **.failed** Unrecoverable error (server refused, TLS failed, timeout)\n- **.cancelled** Task cancelled or connection.cancel() called\n\n---\n\n### 4.3 Send\u002FReceive Patterns\n\n#### Send: Basic\n\n```swift\nlet data = Data(\"Hello\".utf8)\ntry await connection.send(data)\n```\n\n#### Receive: Exact Byte Count (WWDC 7:30)\n\n```swift\n\u002F\u002F Receive exactly 98 bytes\nlet incomingData = try await connection.receive(exactly: 98).content\nprint(\"Received \\(incomingData.count) bytes\")\n```\n\n#### Receive: Variable Length (WWDC 8:29)\n\n```swift\n\u002F\u002F Read UInt32 length prefix, then read that many bytes\nlet remaining32 = try await connection.receive(as: UInt32.self).content\nguard var remaining = Int(exactly: remaining32) else { throw MyError.invalidLength }\n\nwhile remaining > 0 {\n    let chunk = try await connection.receive(atLeast: 1, atMost: remaining).content\n    remaining -= chunk.count\n    \u002F\u002F Process chunk...\n}\n```\n\n#### receive() variants\n- `receive(exactly: n)` — Wait for exactly n bytes\n- `receive(atLeast: min, atMost: max)` — Get between min and max bytes\n- `receive(as: UInt32.self)` — Read fixed-size type (network byte order)\n\n---\n\n### 4.4 TLV Framing (iOS 26+)\n\n**TLV (Type-Length-Value)** solves message boundary problem on stream protocols (TCP\u002FTLS).\n\n#### Format\n- Type: UInt32 (message identifier)\n- Length: UInt32 (message size, automatic)\n- Value: Message bytes\n\n#### Example: GameMessage with TLV (WWDC 11:06, 11:24, 11:53)\n\n```swift\nimport Network\n\n\u002F\u002F Define message types\nenum GameMessage: Int {\n    case selectedCharacter = 0\n    case move = 1\n}\n\nstruct GameCharacter: Codable {\n    let character: String\n}\n\nstruct GameMove: Codable {\n    let row: Int\n    let column: Int\n}\n\n\u002F\u002F Connection with TLV framing\nlet connection = NetworkConnection(\n    to: .hostPort(host: \"www.example.com\", port: 1029)\n) {\n    TLV {\n        TLS()\n    }\n}\n\n\u002F\u002F Send typed message\npublic func sendWithTLV() async throws {\n    let characterData = try JSONEncoder().encode(GameCharacter(character: \"?\"))\n    try await connection.send(characterData, type: GameMessage.selectedCharacter.rawValue)\n}\n\n\u002F\u002F Receive typed message\npublic func receiveWithTLV() async throws {\n    let (incomingData, metadata) = try await connection.receive()\n\n    switch GameMessage(rawValue: metadata.type) {\n    case .selectedCharacter:\n        let character = try JSONDecoder().decode(GameCharacter.self, from: incomingData)\n        print(\"Character selected: \\(character)\")\n    case .move:\n        let move = try JSONDecoder().decode(GameMove.self, from: incomingData)\n        print(\"Move: row=\\(move.row), column=\\(move.column)\")\n    case .none:\n        print(\"Unknown message type: \\(metadata.type)\")\n    }\n}\n```\n\n#### Benefits\n- Message boundaries preserved (send 3 messages → receive exactly 3)\n- Type-safe message handling (enum-based routing)\n- Minimal overhead (8 bytes per message: type + length)\n\n#### When to use\n- Mixed message types (chat + presence + typing)\n- Existing protocols using TLV\n- Need message boundaries without heavy framing\n\n---\n\n### 4.5 Coder Protocol (iOS 26+)\n\n**Coder** eliminates manual JSON encoding\u002Fdecoding boilerplate.\n\n#### Example: GameMessage with Coder (WWDC 12:50, 13:13, 13:53)\n\n```swift\nimport Network\n\n\u002F\u002F Define message types as Codable enum\nenum GameMessage: Codable {\n    case selectedCharacter(String)\n    case move(row: Int, column: Int)\n}\n\n\u002F\u002F Connection with Coder\nlet connection = NetworkConnection(\n    to: .hostPort(host: \"www.example.com\", port: 1029)\n) {\n    Coder(GameMessage.self, using: .json) {\n        TLS()\n    }\n}\n\n\u002F\u002F Send Codable directly (no encoding needed!)\npublic func sendWithCoder() async throws {\n    let selectedCharacter: GameMessage = .selectedCharacter(\"?\")\n    try await connection.send(selectedCharacter)\n}\n\n\u002F\u002F Receive Codable directly (no decoding needed!)\npublic func receiveWithCoder() async throws {\n    let gameMessage = try await connection.receive().content \u002F\u002F Returns GameMessage!\n\n    switch gameMessage {\n    case .selectedCharacter(let character):\n        print(\"Character selected: \\(character)\")\n    case .move(let row, let column):\n        print(\"Move: (\\(row), \\(column))\")\n    }\n}\n```\n\n#### Supported formats\n- `.json` — JSON encoding (human-readable, widely compatible)\n- `.propertyList` — Property list (faster, smaller)\n\n#### Benefits\n- No JSON boilerplate (~50 lines → ~10 lines)\n- Type-safe (compiler catches message structure changes)\n- Automatic framing (handles message boundaries)\n\n#### When to use\n- App-to-app communication (you control both ends)\n- Prototyping (fastest time to working code)\n- Type-safe protocols\n\n#### When NOT to use\n- Interoperating with non-Swift servers\n- Need custom wire format\n- Performance-critical (prefer manual encoding for control)\n\n---\n\n### 4.6 NetworkListener (iOS 26+)\n\nListen for incoming connections with automatic subtask management.\n\n#### Example: Listening for Connections (WWDC 15:16)\n\n```swift\nimport Network\n\n\u002F\u002F Listener with Coder protocol\npublic func listenForIncomingConnections() async throws {\n    try await NetworkListener {\n        Coder(GameMessage.self, using: .json) {\n            TLS()\n        }\n    }.run { connection in\n        \u002F\u002F Each connection gets its own subtask\n        for try await (gameMessage, _) in connection.messages {\n            switch gameMessage {\n            case .selectedCharacter(let character):\n                print(\"Player chose: \\(character)\")\n            case .move(let row, let column):\n                print(\"Player moved: (\\(row), \\(column))\")\n            }\n        }\n    }\n}\n```\n\n#### Key features\n- Automatic subtask per connection (no manual Task management)\n- Structured concurrency (all subtasks cancelled when listener exits)\n- `connection.messages` async sequence for receiving\n\n#### Listener configuration\n\n```swift\n\u002F\u002F Specify port\nNetworkListener(port: 1029) { TLS() }\n\n\u002F\u002F Let system choose port\nNetworkListener { TLS() }\n\n\u002F\u002F Bonjour advertising\nNetworkListener(service: .init(name: \"MyApp\", type: \"_myapp._tcp\")) { TLS() }\n```\n\n---\n\n### 4.7 NetworkBrowser & Wi-Fi Aware (iOS 26+)\n\nDiscover endpoints on local network or nearby devices.\n\n#### Example: Wi-Fi Aware Discovery (WWDC 17:39)\n\n```swift\nimport Network\nimport WiFiAware\n\n\u002F\u002F Browse for nearby paired Wi-Fi Aware devices\npublic func findNearbyDevice() async throws {\n    let endpoint = try await NetworkBrowser(\n        for: .wifiAware(.connecting(to: .allPairedDevices, from: .ticTacToeService))\n    ).run { endpoints in\n        .finish(endpoints.first!) \u002F\u002F Use first discovered device\n    }\n\n    \u002F\u002F Make connection to the discovered endpoint\n    let connection = NetworkConnection(to: endpoint) {\n        Coder(GameMessage.self, using: .json) {\n            TLS()\n        }\n    }\n}\n```\n\n#### Wi-Fi Aware features\n- Peer-to-peer without infrastructure (no WiFi router needed)\n- Automatic discovery of paired devices\n- Low latency, axiom-high throughput\n- iOS 26+ only\n\n#### Browse descriptors\n\n```swift\n\u002F\u002F Bonjour\n.bonjour(type: \"_http._tcp\", domain: \"local\")\n\n\u002F\u002F Wi-Fi Aware (all paired devices)\n.wifiAware(.connecting(to: .allPairedDevices, from: .myService))\n\n\u002F\u002F Wi-Fi Aware (specific device)\n.wifiAware(.connecting(to: .pairedDevice(identifier: deviceID), from: .myService))\n```\n\n---\n\n## NWConnection (iOS 12-25) Complete Reference\n\n### 5.1 Creating Connections\n\nNWConnection uses completion handlers (pre-async\u002Fawait).\n\n#### Basic TLS Connection (WWDC 2018 lines 133-166)\n\n```swift\nimport Network\n\n\u002F\u002F Create connection\nlet connection = NWConnection(\n    host: NWEndpoint.Host(\"mail.example.com\"),\n    port: NWEndpoint.Port(integerLiteral: 993),\n    using: .tls \u002F\u002F TCP inferred\n)\n\n\u002F\u002F Handle connection state changes\nconnection.stateUpdateHandler = { [weak self] state in\n    switch state {\n    case .ready:\n        print(\"Connection established\")\n        self?.sendData()\n\n    case .waiting(let error):\n        print(\"Waiting for network: \\(error)\")\n        \u002F\u002F Show \"Waiting...\" UI, don't fail immediately\n\n    case .failed(let error):\n        print(\"Connection failed: \\(error)\")\n\n    case .cancelled:\n        print(\"Connection cancelled\")\n\n    default:\n        break\n    }\n}\n\n\u002F\u002F Start connection\nconnection.start(queue: .main)\n```\n\n**Critical** Always use `[weak self]` in stateUpdateHandler to prevent retain cycles.\n\n#### Custom Parameters\n\n```swift\n\u002F\u002F Create custom parameters\nlet parameters = NWParameters.tls\n\n\u002F\u002F Prohibit expensive networks\nparameters.prohibitExpensivePaths = true \u002F\u002F Don't use cellular\u002Fhotspot\n\n\u002F\u002F Prohibit constrained networks\nparameters.prohibitConstrainedPaths = true \u002F\u002F Respect low data mode\n\n\u002F\u002F Require IPv6\nparameters.requiredInterfaceType = .wifi\nparameters.ipOptions.version = .v6\n\nlet connection = NWConnection(host: \"example.com\", port: 443, using: parameters)\n```\n\n---\n\n### 5.2 State Handling\n\nNWConnection state machine (same as NetworkConnection):\n\n```\nsetup → preparing → waiting\u002Fready → failed\u002Fcancelled\n```\n\n#### State handling best practices\n\n```swift\nconnection.stateUpdateHandler = { [weak self] state in\n    guard let self = self else { return }\n\n    switch state {\n    case .preparing:\n        \u002F\u002F DNS lookup, TCP SYN, TLS handshake in progress\n        self.updateUI(.connecting)\n\n    case .waiting(let error):\n        \u002F\u002F Network unavailable or blocked\n        \u002F\u002F DON'T fail immediately, framework retries automatically\n        print(\"Waiting: \\(error.localizedDescription)\")\n        self.updateUI(.waiting)\n\n    case .ready:\n        \u002F\u002F Connection established, can send\u002Freceive\n        self.updateUI(.connected)\n        self.startSending()\n\n    case .failed(let error):\n        \u002F\u002F Unrecoverable error after all retry attempts\n        print(\"Failed: \\(error.localizedDescription)\")\n        self.updateUI(.failed)\n\n    case .cancelled:\n        \u002F\u002F connection.cancel() called\n        self.updateUI(.disconnected)\n\n    default:\n        break\n    }\n}\n```\n\n---\n\n### 5.3 Send\u002FReceive with Callbacks\n\n#### Send with Pacing (WWDC 2018 lines 320-341)\n\n```swift\n\u002F\u002F Send with contentProcessed callback for pacing\nfunc sendData() {\n    let data = Data(\"Hello, world!\".utf8)\n\n    connection.send(content: data, completion: .contentProcessed { [weak self] error in\n        if let error = error {\n            print(\"Send error: \\(error)\")\n            return\n        }\n\n        \u002F\u002F contentProcessed = network stack consumed data\n        \u002F\u002F NOW send next chunk (pacing)\n        self?.sendNextData()\n    })\n}\n```\n\n**contentProcessed callback** Invoked when network stack consumes your data (equivalent to when blocking socket call would return). Use this for pacing to avoid buffering excessive data.\n\n#### Receive with Exact Byte Count\n\n```swift\n\u002F\u002F Receive exactly 10 bytes\nconnection.receive(minimumIncompleteLength: 10, maximumLength: 10) { [weak self] (data, context, isComplete, error) in\n    if let error = error {\n        print(\"Receive error: \\(error)\")\n        return\n    }\n\n    if let data = data {\n        print(\"Received \\(data.count) bytes\")\n        \u002F\u002F Process data...\n\n        \u002F\u002F Continue receiving\n        self?.receiveMore()\n    }\n}\n```\n\n#### Receive parameters\n- `minimumIncompleteLength`: Minimum bytes before callback (1 = return any data)\n- `maximumLength`: Maximum bytes per callback\n- For \"exactly n bytes\": Set both to n\n\n---\n\n### 5.4 UDP Batching (WWDC 2018 lines 343-347)\n\n#### Batch sending for 30% CPU reduction.\n\n```swift\n\u002F\u002F UDP connection\nlet connection = NWConnection(\n    host: NWEndpoint.Host(\"game-server.example.com\"),\n    port: NWEndpoint.Port(integerLiteral: 9000),\n    using: .udp\n)\n\nconnection.start(queue: .main)\n\n\u002F\u002F Batch multiple datagrams\nfunc sendVideoFrames(_ frames: [Data]) {\n    connection.batch {\n        for frame in frames {\n            connection.send(content: frame, completion: .contentProcessed { error in\n                if let error = error {\n                    print(\"Send error: \\(error)\")\n                }\n            })\n        }\n    }\n    \u002F\u002F All sends batched into ~1 syscall\n    \u002F\u002F Result: 30% lower CPU usage vs individual sends\n}\n```\n\n**Without batch** 100 datagrams = 100 syscalls = high CPU\n**With batch** 100 datagrams = ~1 syscall = 30% lower CPU (measured with Instruments)\n\n---\n\n### 5.5 NWListener (WWDC 2018 lines 233-293)\n\nAccept incoming connections.\n\n```swift\nimport Network\n\n\u002F\u002F Create listener on port 1029\nlet listener = try NWListener(using: .tcp, on: 1029)\n\n\u002F\u002F Advertise Bonjour service\nlistener.service = NWListener.Service(name: \"MyApp\", type: \"_myapp._tcp\")\n\n\u002F\u002F Handle service registration\nlistener.serviceRegistrationUpdateHandler = { update in\n    switch update {\n    case .add(let endpoint):\n        if case .service(let name, let type, let domain, _) = endpoint {\n            print(\"Advertising: \\(name).\\(type)\\(domain)\")\n        }\n    default:\n        break\n    }\n}\n\n\u002F\u002F Handle new connections\nlistener.newConnectionHandler = { [weak self] newConnection in\n    print(\"New connection from: \\(newConnection.endpoint)\")\n\n    newConnection.stateUpdateHandler = { state in\n        if case .ready = state {\n            print(\"Client connected\")\n            self?.handleClient(newConnection)\n        }\n    }\n\n    newConnection.start(queue: .main)\n}\n\n\u002F\u002F Handle listener state\nlistener.stateUpdateHandler = { state in\n    switch state {\n    case .ready:\n        print(\"Listener ready on port \\(listener.port ?? 0)\")\n    case .failed(let error):\n        print(\"Listener failed: \\(error)\")\n    default:\n        break\n    }\n}\n\n\u002F\u002F Start listening\nlistener.start(queue: .main)\n```\n\n---\n\n### 5.6 NWBrowser (Bonjour Discovery)\n\nDiscover services on local network.\n\n```swift\nimport Network\n\n\u002F\u002F Browse for Bonjour services\nlet browser = NWBrowser(\n    for: .bonjour(type: \"_http._tcp\", domain: nil),\n    using: .tcp\n)\n\n\u002F\u002F Handle discovered services\nbrowser.browseResultsChangedHandler = { results, changes in\n    for result in results {\n        switch result.endpoint {\n        case .service(let name, let type, let domain, _):\n            print(\"Found service: \\(name).\\(type)\\(domain)\")\n\n            \u002F\u002F Connect to this service\n            let connection = NWConnection(to: result.endpoint, using: .tcp)\n            connection.start(queue: .main)\n\n        default:\n            break\n        }\n    }\n}\n\n\u002F\u002F Handle browser state\nbrowser.stateUpdateHandler = { state in\n    switch state {\n    case .ready:\n        print(\"Browser ready\")\n    case .failed(let error):\n        print(\"Browser failed: \\(error)\")\n    default:\n        break\n    }\n}\n\n\u002F\u002F Start browsing\nbrowser.start(queue: .main)\n```\n\n---\n\n## Mobility & Network Transitions\n\n### Connection Viability (WWDC 2018 lines 453-463)\n\nViability = connection can send\u002Freceive data (has valid route).\n\n```swift\nconnection.viabilityUpdateHandler = { isViable in\n    if isViable {\n        print(\"✅ Connection viable (can send\u002Freceive)\")\n    } else {\n        print(\"⚠️ Connection not viable (no route)\")\n        \u002F\u002F Don't tear down immediately, may recover\n        \u002F\u002F Show UI: \"Connection interrupted\"\n    }\n}\n```\n\n#### When viability changes\n- Walk into elevator (WiFi signal lost) → not viable\n- Walk out of elevator (WiFi returns) → viable again\n- Switch WiFi → cellular → not viable briefly → viable on cellular\n\n**Best practice** Don't tear down connection on viability loss. Framework will recover when network returns.\n\n### Better Path Available (WWDC 2018 lines 464-477)\n\nBetter path = alternative network with better characteristics.\n\n```swift\nconnection.betterPathUpdateHandler = { betterPathAvailable in\n    if betterPathAvailable {\n        print(\"? Better path available (e.g., WiFi while on cellular)\")\n        \u002F\u002F Consider migrating to new connection\n        self.migrateToNewConnection()\n    }\n}\n```\n\n#### Scenarios\n- Connected on cellular, walk into building with WiFi → better path available\n- Connected on WiFi, WiFi quality degrades, cellular available → better path available\n\n#### Migration pattern\n\n```swift\nfunc migrateToNewConnection() {\n    \u002F\u002F Create new connection\n    let newConnection = NWConnection(host: host, port: port, using: parameters)\n\n    newConnection.stateUpdateHandler = { [weak self] state in\n        if case .ready = state {\n            \u002F\u002F New connection ready, switch over\n            self?.currentConnection?.cancel()\n            self?.currentConnection = newConnection\n        }\n    }\n\n    newConnection.start(queue: .main)\n\n    \u002F\u002F Keep old connection until new one ready\n}\n```\n\n### Multipath TCP (WWDC 2018 lines 480-487)\n\nAutomatically migrate between networks without application intervention.\n\n```swift\nlet parameters = NWParameters.tcp\nparameters.multipathServiceType = .handover \u002F\u002F Seamless network transition\n\nlet connection = NWConnection(host: \"example.com\", port: 443, using: parameters)\n```\n\n#### Multipath TCP modes\n- `.handover` — Seamless handoff between networks (WiFi ↔ cellular)\n- `.interactive` — Use multiple paths simultaneously (lowest latency)\n- `.aggregate` — Use multiple paths simultaneously (highest throughput)\n\n#### Benefits\n- Automatic network transition (no viability handlers needed)\n- No connection interruption when switching networks\n- Fallback to single-path if MPTCP unavailable\n\n### NWPathMonitor (WWDC 2018 lines 489-496)\n\nMonitor network state changes (replaces SCNetworkReachability).\n\n```swift\nimport Network\n\nlet monitor = NWPathMonitor()\n\nmonitor.pathUpdateHandler = { path in\n    if path.status == .satisfied {\n        print(\"✅ Network available\")\n\n        \u002F\u002F Check interface types\n        if path.usesInterfaceType(.wifi) {\n            print(\"Using WiFi\")\n        } else if path.usesInterfaceType(.cellular) {\n            print(\"Using cellular\")\n        }\n\n        \u002F\u002F Check if expensive\n        if path.isExpensive {\n            print(\"⚠️ Expensive path (cellular\u002Fhotspot)\")\n        }\n\n    } else {\n        print(\"❌ No network\")\n    }\n}\n\nmonitor.start(queue: .main)\n```\n\n#### Use cases\n- Show \"No network\" UI when path.status == .unsatisfied\n- Disable high-bandwidth features when path.isExpensive\n- Adjust quality based on interface type\n\n#### When to use\n- Global network state monitoring\n- When \"waiting for connectivity\" isn't enough\n- Need to know available interfaces before connecting\n\n#### When NOT to use\n- Checking before connecting (use waiting state instead)\n- Per-connection monitoring (use viability handlers instead)\n\n---\n\n## Security Configuration\n\n### TLS Version\n\n```swift\n\u002F\u002F iOS 13+ requires TLS 1.2+ by default\nlet tlsOptions = NWProtocolTLS.Options()\n\n\u002F\u002F Allow TLS 1.2 and 1.3\ntlsOptions.minimumTLSProtocolVersion = .TLSv12\n\n\u002F\u002F Require TLS 1.3 only\ntlsOptions.minimumTLSProtocolVersion = .TLSv13\n\nlet parameters = NWParameters(tls: tlsOptions)\nlet connection = NWConnection(host: \"example.com\", port: 443, using: parameters)\n```\n\n### Certificate Pinning\n\n```swift\n\u002F\u002F Production-grade certificate pinning\nlet tlsOptions = NWProtocolTLS.Options()\n\nsec_protocol_options_set_verify_block(\n    tlsOptions.securityProtocolOptions,\n    { (metadata, trust, complete) in\n        \u002F\u002F Get server certificate\n        let serverCert = sec_protocol_metadata_copy_peer_public_key(metadata)\n\n        \u002F\u002F Compare with pinned certificate\n        let pinnedCertData = Data(\u002F* your pinned cert *\u002F)\n        let serverCertData = SecCertificateCopyData(serverCert) as Data\n\n        if serverCertData == pinnedCertData {\n            complete(true) \u002F\u002F Accept\n        } else {\n            complete(false) \u002F\u002F Reject (prevents MITM attacks)\n        }\n    },\n    .main\n)\n\nlet parameters = NWParameters(tls: tlsOptions)\n```\n\n### Certificate Pinning + Corporate Proxies\n\nCorporate networks often use TLS inspection proxies that present their own certificates. Strict pinning breaks these environments.\n\n**Strategy**: Pin against the public key (SPKI) rather than the full certificate, and provide a configuration escape hatch:\n\n```swift\nsec_protocol_options_set_verify_block(\n    tlsOptions.securityProtocolOptions,\n    { (metadata, trust, complete) in\n        \u002F\u002F 1. Check if system trusts the certificate chain (handles corporate CAs)\n        let secTrust = sec_trust_copy_ref(trust).takeRetainedValue()\n        SecTrustEvaluateAsyncWithError(secTrust, .main) { _, result, _ in\n            guard result else { complete(false); return }\n\n            \u002F\u002F 2. If pinning enabled, also verify public key\n            if PinningConfig.isEnabled {\n                let serverKey = SecTrustCopyKey(secTrust)\n                let matches = pinnedKeys.contains { $0 == serverKey }\n                complete(matches)\n            } else {\n                complete(true) \u002F\u002F System trust only (enterprise mode)\n            }\n        }\n    },\n    .main\n)\n```\n\n**Rules**:\n- Always validate system trust first (`SecTrustEvaluateAsyncWithError`) — this respects enterprise-installed root CAs\n- Use public key pinning over certificate pinning (survives cert rotation)\n- Provide a managed configuration (MDM profile or app config) to disable pinning in enterprise environments\n- Pin at least 2 keys (current + backup) to survive rotation\n\n### Cipher Suites\n\n```swift\nlet tlsOptions = NWProtocolTLS.Options()\n\n\u002F\u002F Specify allowed cipher suites\ntlsOptions.tlsCipherSuites = [\n    tls_ciphersuite_t(rawValue: 0x1301), \u002F\u002F TLS_AES_128_GCM_SHA256\n    tls_ciphersuite_t(rawValue: 0x1302), \u002F\u002F TLS_AES_256_GCM_SHA384\n]\n\n\u002F\u002F iOS defaults to secure modern ciphers, only customize if required\n```\n\n---\n\n## Performance Optimization\n\n### User-Space Networking (WWDC 2018 lines 409-441)\n\n**Automatic on iOS\u002FtvOS.** Network.framework moves TCP\u002FUDP stack into your app process.\n\n#### Benefits\n- ~30% lower CPU usage (measured with Instruments)\n- No kernel→userspace copy (memory-mapped regions)\n- Reduced context switches\n\n#### Legacy vs User-Space\n\n| Traditional Sockets | User-Space Networking |\n|---------------------|----------------------|\n| Packet → driver → kernel → copy → userspace | Packet → driver → memory-mapped region → userspace (no copy) |\n| 100 datagrams = 100 syscalls | 100 datagrams = ~1 syscall (with batching) |\n| ~30% higher CPU | Baseline CPU |\n\n**WWDC demo** Live UDP video streaming showed 30% CPU difference (sockets vs Network.framework).\n\n### ECN for UDP (WWDC 2018 lines 365-378)\n\nExplicit Congestion Notification for smooth UDP transmission.\n\n```swift\n\u002F\u002F Create IP metadata with ECN\nlet ipMetadata = NWProtocolIP.Metadata()\nipMetadata.ecnFlag = .congestionEncountered \u002F\u002F Or .ect0, .ect1\n\n\u002F\u002F Attach to send context\nlet context = NWConnection.ContentContext(\n    identifier: \"video_frame\",\n    metadata: [ipMetadata]\n)\n\nconnection.send(content: data, contentContext: context, completion: .contentProcessed { _ in })\n```\n\n#### ECN flags\n- `.ect0` \u002F `.ect1` — ECN-capable transport\n- `.congestionEncountered` — Congestion notification received\n\n**Benefits** Network can signal congestion without dropping packets.\n\n### Service Class (WWDC 2018 lines 379-388)\n\nMark traffic priority.\n\n```swift\n\u002F\u002F Connection-wide service class\nlet parameters = NWParameters.tcp\nparameters.serviceClass = .background \u002F\u002F Low priority\n\nlet connection = NWConnection(host: \"example.com\", port: 443, using: parameters)\n\n\u002F\u002F Per-packet service class (UDP)\nlet ipMetadata = NWProtocolIP.Metadata()\nipMetadata.serviceClass = .realTimeInteractive \u002F\u002F High priority (voice)\n\nlet context = NWConnection.ContentContext(identifier: \"voip\", metadata: [ipMetadata])\nconnection.send(content: audioData, contentContext: context, completion: .contentProcessed { _ in })\n```\n\n#### Service classes\n- `.background` — Low priority (large downloads, sync)\n- `.default` — Normal priority\n- `.responsiveData` — Interactive data (API calls)\n- `.realTimeInteractive` — Time-sensitive (voice, gaming)\n\n### TCP Fast Open (WWDC 2018 lines 389-406)\n\nSend initial data in TCP SYN packet (saves round trip).\n\n```swift\nlet parameters = NWParameters.tcp\nparameters.allowFastOpen = true\n\nlet connection = NWConnection(host: \"example.com\", port: 443, using: parameters)\n\n\u002F\u002F Send initial data BEFORE calling start()\nlet initialData = Data(\"GET \u002F HTTP\u002F1.1\\r\\n\".utf8)\nconnection.send(\n    content: initialData,\n    contentContext: .defaultMessage,\n    isComplete: false,\n    completion: .idempotent \u002F\u002F Data is safe to replay\n)\n\n\u002F\u002F Now start connection (initial data sent in SYN)\nconnection.start(queue: .main)\n```\n\n**Benefits** Reduces connection establishment time by 1 RTT.\n**Requirements** Data must be idempotent (safe to replay if SYN retransmitted).\n\n---\n\n## Migration Strategies\n\n### From BSD Sockets to NWConnection\n\n| BSD Sockets | NWConnection | Notes |\n|-------------|--------------|-------|\n| `socket() + connect()` | `NWConnection(host:port:using:) + start()` | Non-blocking by default |\n| `send() \u002F sendto()` | `connection.send(content:completion:)` | Async callback |\n| `recv() \u002F recvfrom()` | `connection.receive(min:max:completion:)` | Async callback |\n| `bind() + listen()` | `NWListener(using:on:)` | Automatic port binding |\n| `accept()` | `listener.newConnectionHandler` | Callback per connection |\n| `getaddrinfo()` | Use `NWEndpoint.Host(hostname)` | DNS automatic |\n| `SCNetworkReachability` | `connection.stateUpdateHandler` waiting state | No race conditions |\n| `setsockopt()` | `NWParameters` | Type-safe options |\n\n#### Migration example\n\n#### Before (blocking sockets)\n```c\nint sock = socket(AF_INET, SOCK_STREAM, 0);\nconnect(sock, &addr, addrlen); \u002F\u002F BLOCKS\nsend(sock, data, len, 0);\n```\n\n#### After (NWConnection)\n```swift\nlet connection = NWConnection(host: \"example.com\", port: 443, using: .tls)\nconnection.stateUpdateHandler = { state in\n    if case .ready = state {\n        connection.send(content: data, completion: .contentProcessed { _ in })\n    }\n}\nconnection.start(queue: .main)\n```\n\n### From URLSession StreamTask to NetworkConnection\n\n#### When to migrate\n- Need UDP (StreamTask only supports TCP)\n- Need custom protocols\n- Need low-level control\n\n#### When to STAY with URLSession\n- HTTP\u002FHTTPS (URLSession optimized for this)\n- WebSocket support\n- Built-in caching, cookies\n\n#### Migration example\n\n#### Before (URLSession StreamTask)\n```swift\nlet task = URLSession.shared.streamTask(withHostName: \"example.com\", port: 443)\ntask.resume()\ntask.write(Data(\"Hello\".utf8), timeout: 10) { _ in }\n```\n\n#### After (NetworkConnection iOS 26+)\n```swift\nlet connection = NetworkConnection(to: .hostPort(host: \"example.com\", port: 443)) { TLS() }\ntry await connection.send(Data(\"Hello\".utf8))\n```\n\n### From NWConnection to NetworkConnection\n\n#### Benefits of migration\n- Async\u002Fawait (no callback nesting)\n- No `[weak self]` needed\n- TLV framing built-in\n- Coder protocol for Codable types\n\n#### Migration mapping\n\n| NWConnection | NetworkConnection |\n|--------------|-------------------|\n| `connection.stateUpdateHandler = { }` | `for await state in connection.states { }` |\n| `connection.send(content:completion:)` | `try await connection.send(content)` |\n| `connection.receive(min:max:completion:)` | `try await connection.receive(exactly:)` |\n| Manual JSON | `Coder(MyType.self, using: .json)` |\n| Custom framer | `TLV { TLS() }` |\n| `[weak self]` everywhere | No `[weak self]` needed |\n\n#### Migration example\n\n#### Before (NWConnection)\n```swift\nconnection.stateUpdateHandler = { [weak self] state in\n    if case .ready = state {\n        self?.sendData()\n    }\n}\n\nfunc sendData() {\n    connection.send(content: data, completion: .contentProcessed { [weak self] error in\n        self?.receiveData()\n    })\n}\n```\n\n#### After (NetworkConnection)\n```swift\nTask {\n    for await state in connection.states {\n        if case .ready = state {\n            try await connection.send(data)\n            let received = try await connection.receive(exactly: 10).content\n        }\n    }\n}\n```\n\n---\n\n## Testing Checklist\n\nBefore shipping networking code:\n\n### Device Testing\n- [ ] Tested on real device (not just simulator)\n- [ ] Tested on multiple iOS versions (12, 15, 26)\n- [ ] Tested on iPhone and iPad (different network characteristics)\n\n### Network Conditions\n- [ ] WiFi (home network)\n- [ ] Cellular (disable WiFi)\n- [ ] Airplane Mode → WiFi (test waiting state)\n- [ ] WiFi → cellular transition (walk out of building)\n- [ ] Cellular → WiFi transition (walk into building)\n- [ ] Weak signal (basement, elevator)\n- [ ] Network Link Conditioner (100ms latency, 3% packet loss)\n\n### Network Types\n- [ ] IPv4-only network\n- [ ] IPv6-only network (some cellular carriers)\n- [ ] Dual-stack (IPv4 + IPv6)\n- [ ] Corporate VPN active\n- [ ] Personal hotspot (expensive path)\n\n### Performance\n- [ ] Connection establishment \u003C 500ms (check logs)\n- [ ] Using batch for UDP (verify with Instruments)\n- [ ] Using contentProcessed for pacing (check send timing)\n- [ ] Profiled with Instruments Network template\n- [ ] CPU usage acceptable (\u003C 10% for networking)\n- [ ] Memory stable (no leaks, check [weak self])\n\n### Error Handling\n- [ ] Handling .waiting state (show \"Waiting...\" UI)\n- [ ] Handling .failed state (specific error messages)\n- [ ] TLS handshake errors logged\n- [ ] Timeout handling (don't wait forever)\n- [ ] User-facing errors actionable (\"Check network\" not \"POSIX 61\")\n\n### iOS 26+ Features (if using NetworkConnection)\n- [ ] Using TLV framing if need message boundaries\n- [ ] Using Coder protocol if sending Codable types\n- [ ] Using NetworkListener instead of NWListener\n- [ ] Using NetworkBrowser for Wi-Fi Aware if peer-to-peer\n\n---\n\n## API Quick Reference\n\n### NetworkConnection (iOS 26+)\n\n```swift\n\u002F\u002F Create connection\nNetworkConnection(to: .hostPort(host: \"example.com\", port: 443)) { TLS() }\n\n\u002F\u002F Send\ntry await connection.send(data)\n\n\u002F\u002F Receive\ntry await connection.receive(exactly: n).content\n\n\u002F\u002F States\nfor await state in connection.states { }\n\n\u002F\u002F TLV framing\nNetworkConnection(to: endpoint) { TLV { TLS() } }\n\n\u002F\u002F Coder protocol\nNetworkConnection(to: endpoint) { Coder(MyType.self, using: .json) { TLS() } }\n\n\u002F\u002F Listener\nNetworkListener { TLS() }.run { connection in }\n\n\u002F\u002F Browser\nNetworkBrowser(for: .wifiAware(...)).run { endpoints in }\n```\n\n### NWConnection (iOS 12-25)\n\n```swift\n\u002F\u002F Create connection\nlet connection = NWConnection(host: \"example.com\", port: 443, using: .tls)\n\n\u002F\u002F State handler\nconnection.stateUpdateHandler = { [weak self] state in }\n\n\u002F\u002F Start\nconnection.start(queue: .main)\n\n\u002F\u002F Send\nconnection.send(content: data, completion: .contentProcessed { [weak self] error in })\n\n\u002F\u002F Receive\nconnection.receive(minimumIncompleteLength: min, maximumLength: max) { [weak self] data, context, isComplete, error in }\n\n\u002F\u002F Viability\nconnection.viabilityUpdateHandler = { isViable in }\n\n\u002F\u002F Better path\nconnection.betterPathUpdateHandler = { betterPathAvailable in }\n\n\u002F\u002F Cancel\nconnection.cancel()\n```\n\n### NWListener (iOS 12-25)\n\n```swift\nlet listener = try NWListener(using: .tcp, on: 1029)\nlistener.newConnectionHandler = { newConnection in }\nlistener.start(queue: .main)\n```\n\n### NWBrowser (iOS 12-25)\n\n```swift\nlet browser = NWBrowser(for: .bonjour(type: \"_http._tcp\", domain: nil), using: .tcp)\nbrowser.browseResultsChangedHandler = { results, changes in }\nbrowser.start(queue: .main)\n```\n\n### NWPathMonitor\n\n```swift\nlet monitor = NWPathMonitor()\nmonitor.pathUpdateHandler = { path in }\nmonitor.start(queue: .main)\n```\n\n---\n\n## Resources\n\n**WWDC**: 2018-715, 2025-250\n\n**Docs**: \u002Fnetwork, \u002Fnetwork\u002Fnwconnection, \u002Fnetwork\u002Fnetworkconnection\n\n**Skills**: axiom-networking, axiom-networking-diag\n\n---\n\n**Last Updated** 2025-12-02\n**Status** Production-ready reference from WWDC 2018 and WWDC 2025\n**Coverage** NWConnection (iOS 12-25), NetworkConnection (iOS 26+), all 12 WWDC 2025 code examples\n",{"name":5,"license":15,"metadata":38,"description":7,"compatibility":41},{"version":39,"last-updated":40},"1.0.0","2025-12-02","iOS 12+ (NWConnection), iOS 26+ (NetworkConnection)","main","5b00ad8b9f0787969474ff5e9ec417bb55f23827","skills\u002Fother\u002Fcharleswiltgen-axiom-axiom-network-framework-ref-1.0.2",0,"https:\u002F\u002Fgithub.com\u002FVRIL-LABS\u002Fskill-jam","https:\u002F\u002Fvril.li","https:\u002F\u002Fgithub.com\u002FVRIL-LABS","vril.li","𝗥𝗲𝘀𝗲𝗮𝗿𝗰𝗵 𝗮𝗻𝗱 𝗗𝗲𝘃𝗲𝗹𝗼𝗽𝗺𝗲𝗻𝘁 𝗖𝗼𝗻𝘀𝗼𝗿𝘁𝗶𝘂𝗺","2026-08-24 09:21:38",{"source":8,"skillName":5,"commands":53,"prompt":63,"zipAvailable":64},[54,57,60],{"tool":55,"command":56},"npx","npx skills add VRIL-LABS\u002Fskill-jam --skill axiom-network-framework-ref",{"tool":58,"command":59},"bunx","bunx skills add VRIL-LABS\u002Fskill-jam --skill axiom-network-framework-ref",{"tool":61,"command":62},"pnpm","pnpm dlx skills add VRIL-LABS\u002Fskill-jam --skill axiom-network-framework-ref","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FVRIL-LABS\u002Fskill-jam\u002Fblob\u002Fmain\u002Fskills\u002Fother\u002Fcharleswiltgen-axiom-axiom-network-framework-ref-1.0.2\u002FSKILL.md",true,[],[67,99,113,129,166,189],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":78,"publishedAt":33},"01M6R2CQRG190P09DAHMF8M5QP","three-best-practices","Three.js performance optimization and best practices guidelines. Use when writing, reviewing, or optimizing Three.js code. Triggers on tasks involving 3D scenes, WebGL\u002FWebGPU rendering, geometries, materials, textures, lighting, shaders, or TSL.","https:\u002F\u002Fgithub.com\u002FVRIL-LABS\u002Fskill-jam\u002Fblob\u002Fmain\u002Fskills\u002Fweb-frontend\u002Fneversight-skills_feed-three-best-practices-1.0.2\u002FSKILL.md",[73],{"categoryNo":74,"categoryName":75,"taxonomyType":76,"taxonomyTypeDesc":77},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98],"best practices","three","three best practices","writing","performance","webgpu","guidelines","tasks","code","shaders","Optimization","3D","use","agent-skills","scenes","lighting","triggers","rendering","when","best practices guidelines",{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":33},"01M6R2BPMDYK9XKWPARY0S5MS3","javascript-best-practices","Modern JavaScript best practices and performance optimization guidelines. Use when writing, reviewing, or refactoring JavaScript code to ensure optimal performance, maintainability, and modern patterns.","https:\u002F\u002Fgithub.com\u002FVRIL-LABS\u002Fskill-jam\u002Fblob\u002Fmain\u002Fskills\u002Fweb-frontend\u002Fneversight-skills_feed-javascript-best-practices-1.0.2\u002FSKILL.md",[],[106,79,107,82,83,85,87,89,108,109,91,110,111,112,97],"javascript","JavaScript Best Practices","refactoring","performance optimization","patterns","maintainability","name",{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":122,"publishedAt":33},"01M6R2B41BN09FYH76BAC5FT7X","css-best-practices","Guidelines for building modern, performant, and accessible CSS using MDN best practices. Use this when styling components, fixing layout shifts, or optimizing CSS performance.","https:\u002F\u002Fgithub.com\u002FVRIL-LABS\u002Fskill-jam\u002Fblob\u002Fmain\u002Fskills\u002Fweb-frontend\u002Fneversight-skills_feed-css-best-practices-1.0.3\u002FSKILL.md",[119],{"categoryNo":120,"categoryName":121,"taxonomyType":76,"taxonomyTypeDesc":77},"01JBSEEDCAT000000000000009","前端开发",[123,79,124,83,125,85,91,126,127,128,97],"css","css best practices","components","styling","layout","for",{"skillNo":130,"name":131,"nameZh":6,"description":132,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":133,"categories":134,"keywords":147,"publishedAt":33},"01M6R2A1CEF123TZCNM1XJ2XQ4","frontend-dev","Full-stack frontend development combining premium UI design, cinematic animations,\nAI-generated media assets, persuasive copywriting, and visual art. Builds complete,\nvisually striking web pages with real media, advanced motion, and compelling copy.\nUse when: building landing pages, marketing sites, product pages, dashboards,\ngenerating media assets (image\u002Fvideo\u002Faudio\u002Fmusic), writing conversion copy,\ncreating generative art, or implementing cinematic scroll animations.","https:\u002F\u002Fgithub.com\u002FVRIL-LABS\u002Fskill-jam\u002Fblob\u002Fmain\u002Fskills\u002Fweb-frontend\u002Fminimax-ai-skills-frontend-dev-1.0.1\u002FSKILL.md",[135,136,139,142],{"categoryNo":120,"categoryName":121,"taxonomyType":76,"taxonomyTypeDesc":77},{"categoryNo":137,"categoryName":138,"taxonomyType":76,"taxonomyTypeDesc":77},"01JBSEEDCAT000000000000015","视觉设计",{"categoryNo":140,"categoryName":141,"taxonomyType":76,"taxonomyTypeDesc":77},"01JBSEEDCAT000000000000016","图像与多媒体",{"categoryNo":143,"categoryName":144,"taxonomyType":145,"taxonomyTypeDesc":146},"01JBSEEDCAT000000000000032","设计师","PROFESSION","适用职业",[148,149,150,151,82,152,123,153,154,155,156,157,158,159,160,161,162,163,164,165],"frontend","dev","frontend dev","design","image","react","ui","Video","Media","Audio","Tailwind","stack","music","aida","framer motion","implementing","framer","generative",{"skillNo":167,"name":168,"nameZh":6,"description":169,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":170,"categories":171,"keywords":172,"publishedAt":33},"01M6R20VQ98KDX4J37TGE0FNHW","exa-rate-limits","Implement Exa rate limiting, backoff, and idempotency patterns.\nUse when handling rate limit errors, implementing retry logic,\nor optimizing API request throughput for Exa.\nTrigger with phrases like \"exa rate limit\", \"exa throttling\",\n\"exa 429\", \"exa retry\", \"exa backoff\".","https:\u002F\u002Fgithub.com\u002FVRIL-LABS\u002Fskill-jam\u002Fblob\u002Fmain\u002Fskills\u002Fsearch-research\u002Fjeremylongshore-claude-code-plugins-plus-skills-exa-rate-limits-1.0.0\u002FSKILL.md",[],[173,174,175,176,177,178,179,180,181,110,182,183,184,185,186,163,128,187,188,97],"exa","exa rate limits","rate","limits","throttling","api","read","write","edit","io","throughput","retry","errors","limit","rate limit","request",{"skillNo":190,"name":191,"nameZh":6,"description":192,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":193,"categories":194,"keywords":198,"publishedAt":33},"01M6R20FV0TM7ZZTZNG7JQ1A82","exa-deploy-integration","Deploy Exa integrations to Vercel, Fly.io, and Cloud Run platforms.\nUse when deploying Exa-powered applications to production,\nconfiguring platform-specific secrets, or setting up deployment pipelines.\nTrigger with phrases like \"deploy exa\", \"exa Vercel\",\n\"exa production deploy\", \"exa Cloud Run\", \"exa Fly.io\".","https:\u002F\u002Fgithub.com\u002FVRIL-LABS\u002Fskill-jam\u002Fblob\u002Fmain\u002Fskills\u002Fsearch-research\u002Fjeremylongshore-claude-code-plugins-plus-skills-exa-deploy-integration-1.0.0\u002FSKILL.md",[195],{"categoryNo":196,"categoryName":197,"taxonomyType":76,"taxonomyTypeDesc":77},"01JBSEEDCAT000000000000011","运维与部署",[199,200,173,201,202,203,204,205,206,207,179,180,181,208,209,210,182,211,212,97],"deploy","integration","exa deploy integration","deployment","run","secrets","fly","Bash","integrations","vercel","up","platform","trigger","cloud run"]