How to use sys/socket.h functions in windows OS.

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;
}
}
 
E

eriwik

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.

This is a question better asked in another newsgroup, take a look here
for some suggestions:
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9
 
L

Larry Smith

Ravikumar said:
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.

This is Unix/Linux code (sys/socket.h). You can not
use that in MS Windows. You must include the Windows
socket header instead, and possibly modify the rest of
the program to call Windows socket API's instead of
Unix socket API's.

Ask for further help in a Microsoft Windows/Visual C newsgroup.
This is off-topic for this newsgroup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top