473,395 Members | 1,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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

Dec 4 '06 #1
2 29811
On Dec 4, 2:28 pm, "Ravikumar" <ravikumar1...@gmail.comwrote:
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-lit...t.html#faq-5.9

--
Erik Wikström

Dec 4 '06 #2
Ravikumar wrote:
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.
Dec 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Martin | last post by:
I am a PHP newbie (just got my "Hello World" page working this morning). I'm doing some R&D work to see if PHP is viable for a situation I have. To accomplish what I want to do, I have to have the...
11
by: Mike M | last post by:
Is it possible? In the parent process, I have a socket that binds, listens and then accepts new connections (which creates new sockets in the process). I want to be able to pass some of these new...
5
by: John Sheppard | last post by:
Hi all, I am not sure that I am posting this in the right group but here it goes anyway. I am new to socket programming and I have been searching on the internet to the questions I am about to pose...
1
by: John Sheppard | last post by:
Thanks to everyone that responded to my previous Socket Programming question. Now I have run into some behavior that I don't quite understand. Programming environment. VS.NET 2003, C#, Windows...
9
by: Irmen de Jong | last post by:
Hi, Recently I was bitten by an apparent bug in the BSD socket layer on Open VMS. Specifically, it appears that VMS defines MSG_WAITALL in socket.h but does not implement it (it is not in the...
1
by: Alper AKCAYOZ | last post by:
Hello, I have developped asynchronous socket communication with blocking Socket commands (accept, connect, send, receive) by using threads on Windows .NET Forms. It is working properly. Now I...
4
by: Ravikumar | last post by:
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:...
4
by: Andrew | last post by:
Hi Are these functions (inet_ntop(), inet_pton()) from the socket library supported on Windows. If not is there an equivalent for them using Windows Ive seen mention of people creating...
3
by: Abhinay | last post by:
Hello, I am new in windows socket programing, I am unable to get exact difference between bind() and connect() functions provided by windows( winsock.h) ie when to use bind() and when to use...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.