Member-only story

Naked Networking Not with Bonjour and SwiftUI

Mark Lucking
3 min readFeb 5, 2020

We have over the past six articles developed a simple game of ping/pong, you need to read these articles for the full story.

Naked Networking with SwiftUI
More Naked Networking, more SwiftUI
Naked Networking and SwiftUI, the game plan
Naked Networking and SwiftUI, gamification
Naked Networking and SwiftUI, gamification II
Naked Networking and SwiftUI, gamification III

But we cheated just a little in that we used naked network sockets, hardcoded ones with IP addresses and port numbers. Now it would be possible to get your users to find enter this information in some text fields in your game should you want to ship it to production, but it isn’t very user friendly for 2020. It’s good to know the building blocks behind these things, but today people want more, so lets give them more with Bonjour.

But wait before I launch into code a few words about Bonjour. If you’re from the dark ages like me you will no doubt be a little confused by this protocol initially, looking for ip addresses and port numbers… you won’t find any, but don’t worry cause you don’t need them.

Network

Now to change our app. We start in the Network file Connect.swift. with the listeningUDP method, which gains a parameter and a new line shown here in bold italic.

func listenUDP(zeus: String) {
do {…

--

--

Mark Lucking
Mark Lucking

Written by Mark Lucking

Coding for 35+ years, enjoying using and learning Swift/iOS development. Writer @ Better Programming, @The StartUp, @Mac O’Clock, Level Up Coding & More

No responses yet