当前位置: 技术问答>linux和unix
为什么这个地址用SOCKET发不出去呢
来源: 互联网 发布时间:2015-09-01
本文导语: 这是linux下的ipv6多播程序,多播地址是FF02::C,别的地址如FF03::C都可以发送成功,FF02::c却不行,错误bind:invalid argument 以下是源代码 #include #include #include #include #include #include #include #include ...
这是linux下的ipv6多播程序,多播地址是FF02::C,别的地址如FF03::C都可以发送成功,FF02::c却不行,错误bind:invalid argument
以下是源代码
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//extern int errno;
void start_sender(int sock, struct sockaddr_in6 *sin);
void start_listener(int sock);
int main(int argc, char *argv[])
{
int sock, hops;
unsigned int ifindex;
struct sockaddr_in6 sin;
struct ipv6_mreq mreq;
char ifname[IF_NAMESIZE];
static unsigned char the_addr[16];
//static unsigned char local_addr[16];
inet_pton(AF_INET6, "ff02::c", the_addr);
//inet_pton(AF_INET6, "fe80::205:5dff:fe86:1fd5", local_addr);
if ((sock=socket(AF_INET6, SOCK_DGRAM, 0))
以下是源代码
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//extern int errno;
void start_sender(int sock, struct sockaddr_in6 *sin);
void start_listener(int sock);
int main(int argc, char *argv[])
{
int sock, hops;
unsigned int ifindex;
struct sockaddr_in6 sin;
struct ipv6_mreq mreq;
char ifname[IF_NAMESIZE];
static unsigned char the_addr[16];
//static unsigned char local_addr[16];
inet_pton(AF_INET6, "ff02::c", the_addr);
//inet_pton(AF_INET6, "fe80::205:5dff:fe86:1fd5", local_addr);
if ((sock=socket(AF_INET6, SOCK_DGRAM, 0))