R
Ravikumar
Hi All,
The following code snippet is a part of s/w which is downloaded from
net. While compiling this code I got the following error.
...\..\snmplib\snmpTCPDomain.c(6) : fatal error C1083: Cannot open
include file: 'sys/socket.h': No such file or directory
NMAKE : fatal error U1077: 'cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'C:\PROGRA~1\MICROS~3\VC98\BIN\NMAKE.EXE' :
return code '0x2'
Stop.
I just looked into the code and I found out that the problem is raised
because of sys/socket.h file. So please help me as how to use the
sys/socket.h file in windows OS . I am working on Windows OS. Hence I
am facing the problem.
Please help me as How to resolev this issue . Your thoughts will be
highly appreciated.
Thanks in Advance.
Thanks
Ravikumar
static int
netsnmp_tcp_accept(netsnmp_transport *t)
{
struct sockaddr *farend = NULL;
int newsock = -1, sockflags = 0;
socklen_t farendlen = sizeof(struct sockaddr_in);
char *str = NULL;
farend = (struct sockaddr *) malloc(sizeof(struct sockaddr_in));
if (t != NULL && t->sock >= 0) {
newsock = accept(t->sock, farend, &farendlen);
if (newsock < 0) {
DEBUGMSGTL(("netsnmp_tcp", "accept failed rc %d errno %d
\"%s\"\n",
newsock, errno, strerror(errno)));
free(farend);
return newsock;
}
if (t->data != NULL) {
free(t->data);
}
t->data = farend;
t->data_length = farendlen;
str = netsnmp_tcp_fmtaddr(NULL, farend, farendlen);
DEBUGMSGTL(("netsnmp_tcp", "accept succeeded (from %s)\n",
str));
free(str);
/*
* Try to make the new socket blocking.
*/
#ifdef WIN32
ioctlsocket(newsock, FIONBIO, &sockflags);
#else
if ((sockflags = fcntl(newsock, F_GETFL, 0)) >= 0) {
fcntl(newsock, F_SETFL, (sockflags & ~O_NONBLOCK));
} else {
DEBUGMSGTL(("netsnmp_tcp", "couldn't f_getfl of fd
%d\n",newsock));
}
#endif
return newsock;
} else {
free(farend);
return -1;
}
}
The following code snippet is a part of s/w which is downloaded from
net. While compiling this code I got the following error.
...\..\snmplib\snmpTCPDomain.c(6) : fatal error C1083: Cannot open
include file: 'sys/socket.h': No such file or directory
NMAKE : fatal error U1077: 'cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'C:\PROGRA~1\MICROS~3\VC98\BIN\NMAKE.EXE' :
return code '0x2'
Stop.
I just looked into the code and I found out that the problem is raised
because of sys/socket.h file. So please help me as how to use the
sys/socket.h file in windows OS . I am working on Windows OS. Hence I
am facing the problem.
Please help me as How to resolev this issue . Your thoughts will be
highly appreciated.
Thanks in Advance.
Thanks
Ravikumar
static int
netsnmp_tcp_accept(netsnmp_transport *t)
{
struct sockaddr *farend = NULL;
int newsock = -1, sockflags = 0;
socklen_t farendlen = sizeof(struct sockaddr_in);
char *str = NULL;
farend = (struct sockaddr *) malloc(sizeof(struct sockaddr_in));
if (t != NULL && t->sock >= 0) {
newsock = accept(t->sock, farend, &farendlen);
if (newsock < 0) {
DEBUGMSGTL(("netsnmp_tcp", "accept failed rc %d errno %d
\"%s\"\n",
newsock, errno, strerror(errno)));
free(farend);
return newsock;
}
if (t->data != NULL) {
free(t->data);
}
t->data = farend;
t->data_length = farendlen;
str = netsnmp_tcp_fmtaddr(NULL, farend, farendlen);
DEBUGMSGTL(("netsnmp_tcp", "accept succeeded (from %s)\n",
str));
free(str);
/*
* Try to make the new socket blocking.
*/
#ifdef WIN32
ioctlsocket(newsock, FIONBIO, &sockflags);
#else
if ((sockflags = fcntl(newsock, F_GETFL, 0)) >= 0) {
fcntl(newsock, F_SETFL, (sockflags & ~O_NONBLOCK));
} else {
DEBUGMSGTL(("netsnmp_tcp", "couldn't f_getfl of fd
%d\n",newsock));
}
#endif
return newsock;
} else {
free(farend);
return -1;
}
}