I'm kind of new to zOS and I am developing a small TCP/IP client program in C.
I wrote a prototype program in Linux (Ubuntu) and quickly got it compiled and executed. The result was as expected.
However, when I ported it to USS, It did not even compile. I searched and read a couple of unhelpful articles on IBM's knowledge centre, and finally got totally lost.
Here is a simplified version of the program: (the concrete questions are in the comment of the code)
#pragma langlvl(stdc99)
#define _XOPEN_SOURCE_EXTENDED 1
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
int main(int argc, char const *argv[])
{
/* ... ... ... */
struct addrinfo hint = {0};
hint.ai_flags = AI_CANONNAME;
hint.ai_family = AF_INET;
hint.ai_socktype = SOCK_STREAM;
hint.ai_protocol = 0;
/* HERE COMES THE 1ST PROBLEM: no matter what I did, the compiler just couldn't find anything from netdb.h. AI_CANONNAME not found, getaddrinfo not found either */
int rc = getaddrinfo(hostname, "", &hint, &result);
/* ... ... ... */
/* HERE COMES THE 2ND PROBLEM: 'socket' was found after I added the #pragma and the #define, BUT the linker couldn't find the module for the symbol 'socket' so I couldn't produce the executable file. I simply used the following command to build it:
c99 -o test test.c
*/
sock = socket(AF_INET, SOCK_STREAM, 0);
/* ... ... ... */
return 0;
}
IBM really has very limited articles that about these, so I really need help with it.
1. Why c89 compiler (and xlc did the same) failed to find getaddrinfo() ?
2. What linker options I need to use ?
Thank you very very much !!