Swift Network TCP受信 コネクション

概要

ソース

コネクション

import Network

print("recieve")
let myQueue  = DispatchQueue.global()
do {
    let listener = try NWListener(using: .tcp, on: 8090)
    listener.newConnectionHandler = { (newConnection) in
        // Handle inbound connections
        print("connection ok")
        newConnection.start(queue: myQueue)
    }
    print("listener start")
    listener.start(queue: myQueue)
}
catch {
    print(error)
}
sleep(60)
print("end")

Swift

Posted by shi-n