标签云

微信群

扫码加入我们

WeChat QR Code

I've been having issues getting the C sockets API to work properly in C++. Specifically, although I am including sys/socket.h, I still get compile time errors telling me that AF_INET is not defined. Am I missing something obvious, or could this be related to the fact that I'm doing this coding on z/OS and my problems are much more complicated?


Update: Upon further investigation, I discovered that there is an #ifdef that I'm hitting. Apparently z/OS isn't happy unless I define which "type" of sockets I'm using with:

#define _OE_SOCKETS

Now, I personally have no idea what this _OE_SOCKETS is actually for, so if any z/OS sockets programmers are out there (all 3 of you), perhaps you could give me a rundown of how this all works?


Sure I can post a test app.

#include <sys/socket.h>

int main()
{
    return AF_INET;
}

Compile/Link Output:

cxx -Wc,xplink -Wl,xplink -o inet_test inet.C

"./inet.C", line 5.16: CCN5274 (S) The name lookup for "AF_INET" did not find a declaration.

CCN0797(I) Compilation failed for file ./inet.C. Object file not created.

A check of sys/sockets.h does include the definition I need, and as far as I can tell, it is not being blocked by any #ifdef statements.

I have however noticed it contains a the following:

#ifdef __cplusplus
  extern "C" {
#endif

which encapsulates basically the whole file. Not sure if it matters.


z/OS has as much in common with z/VM as Windows does with Linux, so I'm a little bemused why you posted that link.

2018年07月19日38分28秒

Notice that the _OE_SOCKETS macro appears in both, and seems to have the same purpose. Which is not surprising, since probably IBM used the same code base for socket support in both products. I did not intend to say that z/VM documentation applies to z/OS, it's just the most similar case I found.

2018年07月19日38分28秒

I think it's just a coincidence. z/VM doesn't use the z/OS Language Environment product, which provides the relevant header files used to make socket calls.

2018年07月19日38分28秒

This has nothing to do with the the original question.

2018年07月19日38分28秒