相关文章推荐
473,691 Members | 1,924 Online

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\MI CROS~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_acc ept(netsnmp_tra nsport *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(s truct sockaddr_in));

if (t != NULL && t->sock >= 0) {
newsock = accept(t->sock, farend, &farendlen);

if (newsock < 0) {
DEBUGMSGTL(("ne tsnmp_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_fmt addr(NULL, farend, farendlen);
DEBUGMSGTL(("ne tsnmp_tcp", "accept succeeded (from %s)\n",
str));
free(str);

* Try to make the new socket blocking.
#ifdef WIN32
ioctlsocket(new sock, FIONBIO, &sockflags);
#else
if ((sockflags = fcntl(newsock, F_GETFL, 0)) >= 0) {
fcntl(newsock, F_SETFL, (sockflags & ~O_NONBLOCK));
} else {
DEBUGMSGTL(("ne tsnmp_tcp", "couldn't f_getfl of fd
%d\n",newsock)) ;
#endif

return newsock;
} else {
free(farend);
return -1;
Dec 4 '06 # 1
2 29868
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\s nmpTCPDomain.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\MI CROS~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

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\s nmpTCPDomain.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\MI CROS~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

6368
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 PHP page communicate directly with another process. I want the PHP script to establish a socket connection to the other process, send a message and receive some data back which would then used for calculations and/or display on the resulting... 6857
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 sockets to a spawned process. Is it possible, and if so how? Any help is much appreciated!!
3679
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 but have been unsuccessful in finding the answers so far. Either because my understanding of sockets isn't where it needs to be or my questions are too basic. My programming environment is Windows XP, Visual Studio .NET 2003 and C#. So here it...
3389
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 XP. About the architecture: I have a socket server dll that contains a class that handles connections for a given local ipaddress and port. This class(server) can be started or stopped by calls to the appropriate functions. The server class has...
2150
by: Irmen de Jong | last post by: 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 documentation). And I use the socket.MSG_WAITALL flag on my recv() calls... and then they crash on OpenVMS. I don't have access to an OpenVMS machine myself so could someone else that has (or has more knowledge of it) shed some light on it?
6677
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 want to code the similar program with Asynchronous Socket commands of .NET using Managed C++ on Windows .NET Forms. My problem is with delegates. I have to use "static" methods as parameter in delegate constructor like below:...
1196
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: 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' :
5053
by: Andrew | last post by: 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 their own in order to use them Appreciate the help
4245
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 connect() functions. can any budy help me to solve my problem. In order to know internal working of windows socket which doc/link should i refer ??? thanks in advance. Abhinay
8599
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
8533
by: Hystou | last post by: Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
9079
by: Oralloy | last post by: Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
8951
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
8791
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
7624
by: agi2029 | last post by: Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
6457
by: isladogs | last post by: The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
4322
by: TSSRALBI | last post by: Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1954
by: bsmnconsultancy | last post by: In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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

 
推荐文章