Socket Demo Samples shows how to use various Apple APIs to run a TCP connection, including: SocketStream URLSessionStreamTask NWTCPConnection