当前位置: 技术问答>linux和unix
为什么我的setsockopt()总提示setsockopt: No such device
来源: 互联网 发布时间:2015-12-21
本文导语: 前面几个API都能通过,但是在最后一个if()语句时,setsockopt()出错,提示:“setsockopt: No such device”,请高手救命,是不是我的代码写的有问题,还是相关设备设置有问题。 代码如下: #define MAXBUF 9000 #define MAXNEW...
前面几个API都能通过,但是在最后一个if()语句时,setsockopt()出错,提示:“setsockopt: No such device”,请高手救命,是不是我的代码写的有问题,还是相关设备设置有问题。
代码如下:
#define MAXBUF 9000
#define MAXNEWS 1024
#define PUERTO 1234
#define GRUPO "224.0.0.1"
#define MSG_MAGIC "1234567"
#define MSG_MAGIC_LEN 8
#define TYPE_FROM_CM_TITLE 2
#define TITLE_CONTENT 2
#define ENCRYPTION_PASSWORD "123"
int socket_test()
{
int s,n,r, tmplen;
struct sockaddr_in srv,cli;
struct ip_mreq mreq;
BYTE buf[MAXBUF], *pnews, *plogo;
unsigned char previd[10];
int datalen, first=1;
BYTE btPacketID=1;
unsigned int len1, len2;
memset(previd, 0 , 10);
bzero(&srv, sizeof(srv));
srv.sin_family = AF_INET;
srv.sin_port = htons(PUERTO);
if(inet_aton(GRUPO, &srv.sin_addr)
代码如下:
#define MAXBUF 9000
#define MAXNEWS 1024
#define PUERTO 1234
#define GRUPO "224.0.0.1"
#define MSG_MAGIC "1234567"
#define MSG_MAGIC_LEN 8
#define TYPE_FROM_CM_TITLE 2
#define TITLE_CONTENT 2
#define ENCRYPTION_PASSWORD "123"
int socket_test()
{
int s,n,r, tmplen;
struct sockaddr_in srv,cli;
struct ip_mreq mreq;
BYTE buf[MAXBUF], *pnews, *plogo;
unsigned char previd[10];
int datalen, first=1;
BYTE btPacketID=1;
unsigned int len1, len2;
memset(previd, 0 , 10);
bzero(&srv, sizeof(srv));
srv.sin_family = AF_INET;
srv.sin_port = htons(PUERTO);
if(inet_aton(GRUPO, &srv.sin_addr)