简体   繁体   中英

How to convert a multicast address string to in_addr or in_addr6

I'm writing a program where a datagram socket should be able to receive multicast datagrams. I already found out that before a host can receive IP multicast datagrams, the host must become a member of one, or more IP multicast groups with a setsockopt() call. The application should work for both IPv4 and IPv6.

The thing that i don't know is how to properly convert my IPv4/IPv6 multicast address string for example "ff14::60" into a in_addr or in_addr6 struct for the different setsockopt() calls.

I appreciate your help and suggestions!

The inet_pton() function can be used for this according to the manpage .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM