Send and receive UDP broadcasts from the previous C #
Http://www.cnblogs.com/JimmyBright/p/4637090.html
Using Asyncudpsocket to process UDP messages in iOS is very convenient
Preparatory work:
Find Cocoaasyncsocket on GitHub, download it, copy the AsyncUdpSocket.h and ASYNCUDPSOCKET.M files to your project, and no other files are needed. Copy to the SWIFT environment will automatically prompt to create the bridge file, click on the confirmation.
Send UDP:
The above code broadcasts the message "Hello worldxxxx" to the LAN, and has been tested to successfully receive the broadcast message in the UDP broadcast of the previous C #
Receive UDP:
The above mentioned C # version of UDP, every 1 seconds to send an IP out, tested in iOS can successfully receive the IP, of course, the above code can only be received once, if you want to keep listening, you need to create a loop.
UDP broadcast send and receive (Ios+asyncudpsocket) next