Just how to make use of the C outlet API in C++ on z/OS

I'm having concerns obtaining the C sockets API to function effectively in C++ on z/OS.

Although I am consisting of sys/socket.h, I still get compile time mistakes informing me that AF_INET is not specified.

Am I missing out on something noticeable, or is this pertaining to the reality that getting on z/OS makes my troubles far more made complex?


Update: Upon more examination, I uncovered that there is an #ifdef that I'm striking. Evidently z/OS isn't satisfied unless I specify which "type" of sockets I'm making use of with:

#define _OE_SOCKETS

Currently, I directly have no suggestion what this _OE_SOCKETS is in fact for, so if any kind of z/OS sockets designers are around (all 3 of you), probably you could offer me a run-through of just how this all jobs?


Examination 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 require, and also regarding I can inform, it is not being obstructed by any kind of #ifdef declarations.

I have actually nonetheless seen it has the adhering to:

#ifdef __cplusplus
  extern "C" {
#endif

which envelops primarily the entire documents. Not exactly sure if it matters.

0
2019-05-07 00:09:08
Source Share
Answers: 2

I've had no problem making use of the BSD sockets API in C+npls, in GNU/Linux. Below's the example program I made use of :

#include <sys/socket.h>

int
main()
{
    return AF_INET;
}

So my take on this is that z/OS is possibly the complicating variable below, nonetheless, due to the fact that I've never ever made use of z/OS prior to, a lot less set in it, I can not claim this definitively. : - P

0
2019-05-08 20:46:50
Source

@Jax : The extern "C" point issues, really significantly. If a header documents does not have one, after that (unless it's a C+npls - just header documents), you would certainly need to confine your #include with it :

extern "C" {
#include <sys/socket.h>
// include other similarly non-compliant header files
}

Basically, anytime where a C+npls program intends to link to C - based centers, the extern "C" is essential. In sensible terms, it suggests that the names made use of in exterior referrals will certainly not be mangled, like regular C+npls names would certainly. Reference.

0
2019-05-08 20:44:04
Source