Skip to content

emlynmac/udpconnection

Repository files navigation

UdpConnection

Am async wrapper around Network's NWConnection, for User Datagram Protocol

Usage:

let connection = UdpConnection.live(url: yourUrl, queue: yourDispatchQueue)

// Send with 
connection.send(data)

// Receive by awaiting the data on the receivedData stream:
for await data in connection.receivedData {
  // DO SOMETHING WITH THE DATA
}
  
// Track errors and state with the connectionState stream:
Task {
  for await state in connection.connectionState {
      switch state {
    case .ready:
      // Start sending / receiving
      
    default:
      // Handle other things
    }
  }
}

About

Stream wrapper for Swift Network.NWConnection

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages