How to use the C socket API in C++ on z/OS

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? ;)

This question and answers originated from www.stackoverflow.com
Question by (8/1/2008 12:13:50 PM)

Answer

Keep a copy of the IBM manuals handy:

z/OS V1R11.0 XL C/C++ Run-Time Library Reference z/OS V1R11.0 XL C/C++ Programming Guide

The IBM publications are generally very good, but you need to get used to their format, as well as knowing where to look for an answer. You'll find quite often that a feature that you want to use is guarded by a "feature test macro"

You should ask your friendly system programmer to install the XL C/C++ Run-Time Library Reference: Man Pages on your system. Then you can do things like "man connect" to pull up the man page for the socket connect() API. When I do that, this is what I see:

FORMAT

X/Open

#define _XOPEN_SOURCE_EXTENDED 1
#include <sys/socket.h>

int connect(int socket, const struct sockaddr *address, socklen_t address_len);

Berkeley Sockets

#define _OE_SOCKETS
#include <sys/types.h>
#include <sys/socket.h>

int connect(int socket, struct sockaddr *address, int address_len);
Answer by

Find More Answers
Related Topics  c++  c  sockets  mainframe  zos
Related Questions
  • Replace the C socket API in C++ on z/OS

    I am including sys/socket.h, I still get compile time errors telling me that AF_INET is not defined. but still i am facing the issues getting the C sockets API to work properly in C++. please help m…
  • using WTO to print from with in Metal C

    I’m trying to use the WTO instruction from with in Metal C to print out "Hello World" to my job log. This is based on the example in section 1.2.3.5 of the z/OS V1R10.0 Metal C Programming Guide and…
  • problems with memset in Metal C

    I’m trying to initialize the Metal C environment with the following code, but get the following errors on the memset line. ERROR CCN3275 IMIJWS0.METAL.SAMPLIB(MEM):6 Unexpected text ')' encountere…
  • z/OS socket creation - compilation issues

    I am trying to create a client application relying on raw sockets. I refereed http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/EDCLB1A0/3.940.2?SHELF=&DT=20090607203246&CASE= for h…
  • How to match strings in a DB2 (z/OS) query?

    This is blowing my mind. All I want to do is basic string comparison on a long varchar field. I have a table of approx. 12M records. If I query for MY_FIELD='a string' , I get a count of 25…
  • C++ Unit-Testing Framework for z/OS (IBM Mainframe)

    Does anyone know of a C++ unit-testing framework (e.g. CppUnit , Google Test , etc.) that can be used to write tests on z/OS ? I do most of my development on Windows using the Dignus C++ compiler…
  • Connecting to DB2 from USS on z/OS mainframe

    I am writing a C program in Unix System Services on a z/OS mainframe. One of the requirements is to get a sequence number from a DB2 database residing on the same mainframe. Not having DB2 Connect a…
  • Set default tablespace in JDBC URL for db2 on Z/OS?

    Is it possible to force all create table statements to use a specific database.tablespace by passing a parameter to the JDBC URL? For example instead of manually specifying it as follows CREATE T…
  • teaching my self Z/OS assembler?

    'I've interned at a company that does a lot of mainframe work. Most of my mainframe experience has been using Java and Unix System Services. I've had some experience with the ISPF interface and C bu…
  • Gnu Make and z/OS USS make

    1) We have a need for Makefiles to build C++ on both z/OS USS and a Linux platform. Is it advisable to use gnu make on z/OS USS in order to keep our makefiles common ? 2) If the Makefiles are com…