Int main()
{
Int sockfd;
Struct sockaddr_in server_addr, client_addr;
Int broadcast_en = 1;
Socklen_t broadcast_len = sizeof(broadcast_en);
Char buf[] = "good luck";
Bzero(&server_addr, sizeof(server_addr));
Bzero(&client_addr, sizeof(client_addr));
Server_addr.sin_family = AF_INET;
Server_addr.sin_port = htons(2222);
Server_addr.sin_addr.s_add=inet_addr("192.168.220.255");
Sockfd = socket(AF_INET, SOCK_DGRAM, 0);
Setsocketopt(sockfd, SOL_SOCKET, SO_BROADCAST, &broadcast_en, broadcast_len);
Sendto(sockfd, buf, sizeof(buf), 0, (struct sockaddr *)&clinet_addr, sizeof(client_addr));
}
|