Is content my bytes to send?
Yes.
Why is it optional?
Because you might want to send metadata without sending data. This more often crops up in datagram-based protocols rather than stream-based protocols (like TCP). However, even in TCP there is one case of interest here, namely EOF. If you want to end the send side of a TCP connection without sending any data, you’d pass nil to
content
and true to
isComplete
.
What is
isComplete
supposed to be set as?
Again, this is more interesting in the datagram case. For TCP, see above.
Are there even any examples/sample code for this stuff?
In terms of official sample code, the only one currently available is nwcat. This uses the C API, but most of the concepts just map across.
On the Swift front, I’ve been working on that but my ‘day job’ (answering questions) keeps getting in the way )-: I posted some preliminary snippets to this Swift Forums thread.
Or is it just too early to be delving into this?
Not IMO. My experience with Network framework has been very positive, especially when using it from Swift. There’s still a few things you can’t do — like UDP multicast — but for the things you can do it tends to work really well.
Keep in mind that the underlying code for Network framework (the private
libnetcore
library) is also used by CFNetwork, so the core code is very solid because it’s exercised every time someone uses
URLSession
.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"