title: How to use the C socket API in C++ on z/OS
body: <p>I'm having issues getting the C sockets API to work properly in C++ on z/OS.</p>
  <p>Although I am including <code>sys/socket.h</code>, I still get compile time errors telling me that <code>AF_INET</code> is not defined.</p>
  <p>Am I missing something obvious, or is this related to the fact that being on z/OS makes my problems much more complicated?</p>
  <p>I discovered that there is an <code>#ifdef</code> that I'm hitting. Apparently z/OS isn't happy unless I define which &quot;type&quot; of sockets I'm using with:</p>
  <pre><code>#define _OE_SOCKETS
  </code></pre>
  <p>Now, I personally have no idea what this <code>_OE_SOCKETS</code> 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?</p>
  <p>Test App</p>
  <pre><code>#include &lt;sys/socket.h&gt;
  
  int main()
  {
      return AF_INET;
  }
  </code></pre>
  <p>Compile/Link Output:</p>
  <pre><code>cxx -Wc,xplink -Wl,xplink -o inet_test inet.C
  
  &quot;./inet.C&quot;, line 5.16: CCN5274 (S) The name lookup for &quot;AF_INET&quot; did not find a declaration.
  CCN0797(I) Compilation failed for file ./inet.C. Object file not created.
  </code></pre>
  <p>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 <code>#ifdef</code> statements.</p>
  <p>I have however noticed it contains the following:</p>
  <pre><code>#ifdef __cplusplus
    extern &quot;C&quot; {
  #endif
  </code></pre>
  <p>which encapsulates basically the whole file? Not sure if it matters.</p>