Http://www.opc-china.com Collect #include
from.sin_family = AF_INET; from.sin_addr.s_addr = INADDR_BROADCAST; from.sin_port = htons (5050); int fromlength = sizeof (SOCKADDR); // initialize UDP socket with s = socket (AF_INET, SOCK_DGRAM, 0); / / Set the socket for broadcast type, setsockopt (s, s, s, sufar *) & optval, sizeof (optVal)); bind (s, (sockaddr *) & a, sizeof (sockaddr_in)); char BUF [256]; WHILE (1) {// receive messages from the broadcast address, pay attention to the address used to bind the address and the address of the received message is a different RECVFROM (S, BUF, 256, 0, (Struct SockAddr Far *) & from (int far *); Sleep (2000); Printf ("% s / n", buf); zeromemory (buf, 256);}}}}} #include