Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / December 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ravikumar - 04 Dec 2006 13:49 GMT
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. Is there any library I missed out.

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;
   }
William DePalo [MVP VC++] - 04 Dec 2006 15:55 GMT
> The following code snippet is a part of s/w which is downloaded from
> net. While compiling this code I got the following error.
[quoted text clipped - 6 lines]
> return code '0x2'
> Stop.

Did you get a file named socket.h with the software that you downloaded? If
so, where is it? If it is in some directory with a name like

   ...\sys\socket.h

you need to make sure that the directory that I omitted "..." is one of the
include directories that the compiler searches.

On the other hand, if the software that you downloaded was truly intended to
run on Windows it just might use the file <winsock[2].h> instead to define
things related to sockets.

Of course, it's impossible for any of _us_ to be able to tell _you_ if you
have downloaded Windows or Linux source (or anything else).

Regards,
Will

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.