UDP socket

1.Udp: User Datagram Protocol (Udp) User Datagram Protocol.

2. It is suitable for communication between hosts in the local area network.

3. How to use

    1: Create Socket

      OS_Socket local(127.0.0.1",9000);

      OS_UdpSocket sock;

      sock.Open(local,true);

      2: receive

       char buf[128];

       OS_SockAddr peer;//The address of the peer

       int n= sock.RecvFrom(buf,128,peer);

    3. Destroy the Socket

       sock.Close();

(127.0.0.1 represents the local address, it loops back directly in the system without going through the network card, and wireshark cannot detect it)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324898259&siteId=291194637