https://github.com/dashersw/docker-cloud-multicast/blob/master/mcreceive.c个
$ ./mcreceive X.X.X.X 60001
其中,X.X是组播地址
Received 28 bytes from X.X.X.X: Ϭ(
Received 28 bytes from X.X.X.X: Ϭ(
Received 28 bytes from X.X.X.X: Ϭ(
Received 28 bytes from X.X.X.X: Ϭ(
Received 56 bytes from X.X.X.X: Ϭ(
Received 28 bytes from X.X.X.X: (
Received 28 bytes from X.X.X.X: Ϭ(
Received 56 bytes from X.X.X.X: Ϭ(
Received 168 bytes from X.X.X.X: Ϭ(
Received 28 bytes from X.X.X.X: %Ϭ(
Received 28 bytes from X.X.X.X: &Ϭ(
Received 28 bytes from X.X.X.X: 'Ϭ(
Ethernet II: 18 bytes
IP: Minimum 20 bytes (can be more with options)
UDP: 8 bytes
相关源代码:
/* create socket to join multicast group on */
if ((sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
perror("socket() failed");
exit(1);
}
...
/* block waiting to receive a packet */
if ((recv_len = recvfrom(sock, recv_str, MAX_LEN, 0,
(struct sockaddr*)&from_addr, &from_len)) < 0) {
perror("recvfrom() failed");
exit(1);
}
/* output received string */
printf("Received %d bytes from %s: ", recv_len,
inet_ntoa(from_addr.sin_addr));
如你所见,我收到了几个长度为28的包.如何接收长度小于18+20+8的UDP数据包?