swiftsocket / SwiftSocket

The easy way to use sockets on Apple platforms
BSD 3-Clause "New" or "Revised" License
1.68k stars 401 forks source link

UDPServer listen to asynch messages #105

Open dddppp opened 7 years ago

dddppp commented 7 years ago

Hello,

How can I write some test code to listen to UDPServer incoming messages asynchronously?

Loop pseudocode:

I wrote this little code but it does not seem to respond to incoming messages. I am running a server on the same address and port which sends data out.

    func testServer() {
        let server = UDPServer(address: host, port: Int32(port))

        while true {
            let received = server.recv(4)
            print(received)
        }
    }
SNThunderbolt commented 6 years ago

hi @dddppp, I have this question too :( could you find any answer for it?