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



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
[...]

Socket programming (which is OT for clc anyway) is different for
Windows than it is for *nix systems. For Windows, you will need
to read up on "winsock" routines. Many things match up in winsock
to "normal" sockets, but there are many differences as well.

You'll need to ask one of the Windows programming groups for more
specifics. I'm not sure which one would be appropriate.

Here is a (very-OT) sample of the start of a module which accesses
sockets on both Windows and *nix. Take it to an appropriate winsock
group for any questions you may have.

==========
#if DOS_NT

#include <winsock.h>
#define SocketErrno (WSAGetLastError())
#define bcopy(src,dest,len) memmove(dest,src,len)

#else

#include <sys/socket.h>
#include <sys/poll.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/select.h>

#define SocketErrno errno

#define SOCKET int
#define SOCKET_ERROR -1
#define INVALID_SOCKET -1

#endif
==========

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:ThisIsASpamTrap@xxxxxxxxx>

.



Relevant Pages

  • Re: Okay to create a socket PRIOR to ip configuration?
    ... > Microsoft MVP, MCSD ... >>I am experiencing some intermittent problems with winsock. ... >> windows systems should be communicating over winsock. ... >> socket has already been created. ...
    (microsoft.public.win32.programmer.networks)
  • Re: Okay to create a socket PRIOR to ip configuration?
    ... >> You haven't specified proper service dependencies for your ... >>>I am experiencing some intermittent problems with winsock. ... >>> windows systems should be communicating over winsock. ... >>> socket has already been created. ...
    (microsoft.public.win32.programmer.networks)
  • Re: Can you recommand a book about socket(tcp/ip) programming for windows CE
    ... there really are few differences for the average socket program. ... If you have to have a book to make you feel better, WinSock on Windows CE is ...
    (microsoft.public.windowsce.embedded)
  • Re: multi-threaded server
    ... internally it uses WaitForMultipleObjects to wait on socket handles ... that's only a Windows limitation. ... |> limitation of selectin WinSock. ...
    (microsoft.public.win32.programmer.networks)
  • Re: help me with my understanding of WSPRecv/From
    ... WinSock has some MS-specific functions to employ the NT ... WinSock has a common provider DLL called MSAFD.DLL. ... AFD.SYS is a kernel module which implements the sockets semantics on top of ... This will give you lots of socket stuff, ...
    (microsoft.public.development.device.drivers)