Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 1440916 Details for
Bug 1582030
Multicast does not work in RHVM
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
multicast_client.c
multicast_client.c (text/x-csrc), 2.12 KB, created by
xiywang
on 2018-05-24 02:32:21 UTC
(
hide
)
Description:
multicast_client.c
Filename:
MIME Type:
Creator:
xiywang
Created:
2018-05-24 02:32:21 UTC
Size:
2.12 KB
patch
obsolete
>#include <sys/types.h> >#include <sys/socket.h> >#include <arpa/inet.h> >#include <netinet/in.h> >#include <stdio.h> >#include <stdlib.h> >#include <string.h> >#include <unistd.h> > > >#define MCAST_PORT 8888 >#define MCAST_ADDR "224.0.0.88" /*multicast ip*/ >#define MCAST_INTERVAL 3 >#define BUFF_SIZE 256 > > >int main(int argc, char *argv[]) >{ > int s; > int err = -1; > struct sockaddr_in local_addr; > > s = socket(AF_INET, SOCK_DGRAM, 0); > if (s < 0) > { > perror("Opening datagram socket error"); > exit(1); > } > else > { > printf("Opening the datagram socket ...OK\n"); > } > memset((char *)&local_addr, 0, sizeof(local_addr)); > local_addr.sin_family = AF_INET; > local_addr.sin_addr.s_addr = htonl(INADDR_ANY); > local_addr.sin_port = htons(MCAST_PORT); > > /*Bind the socket*/ > err = bind(s, (struct sockaddr *)&local_addr, sizeof(local_addr)); > if (err < 0) > { > perror("bind()"); > return -2; > } > > /*Prevent multicast loop*/ > int loop = 1; > err = setsockopt(s, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof(loop)); > if (err < 0) > { > perror("setsockopt(): IP_MULTICAST_LOOP"); > return -3; > } > > struct ip_mreq mreq; > mreq.imr_multiaddr.s_addr = inet_addr(MCAST_ADDR); > mreq.imr_interface.s_addr = htonl(INADDR_ANY); > > /*Add local machine to multicast group*/ > err = setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)); > if (err < 0) > { > perror("setsockopt(): IP_ADD_MEMBERSHIP"); > return -4; > } > > int times = 0; > int addr_len = 0; > char buff[BUFF_SIZE]; > int n = 0; > > for (times = 0; times < 5; times++) > { > addr_len = sizeof(local_addr); > memset(buff, 0, BUFF_SIZE); > n = recvfrom(s, buff, BUFF_SIZE, 0, (struct sockaddr *)&local_addr, &addr_len); > if (n == 1) > { > perror("recvform()"); > } > printf("Recv %dst message from server:%s\n", (times + 1), buff); > sleep(MCAST_INTERVAL); > } > > /*Exit from the multicast group*/ > err = setsockopt(s, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)); > close(s); > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1582030
: 1440916 |
1440917