Is it possible to somehow use the winsock API on a unix machine?

Recommended Answers

All 3 Replies

No. use POSIX sockets. The two are a lot alike so it shouldn't be all that difficutl to port from MS-Windows to *nix.

Ok, so if on my unix box I see a call to:

#if INCL_WINSOCK_API_PROTOTYPES
WINSOCK_API_LINKAGE
int
WSAAPI
connect(
    IN SOCKET s,
    __in_bcount(namelen) const struct sockaddr FAR * name,
    IN int namelen
    );
#endif /* INCL_WINSOCK_API_PROTOTYPES */

Does that mean something's not right?

>>Does that mean something's not right?
No, it means the code has been ported to both MS-Windows and *nix. If compiling on MS-Windows then define INCL_WINSOCK_API_PROTOTYPES somewhere before the code snippet you posted. Using preprocessor instructions like that is a common way to write portable programs that are compiled with different compilers and/or operating systems.

Use of the FAR macro would leave me to believe the code was written for some 16-bit segmented MS-DOS compiler. 32-bit compilers do not use FAR.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.