Communications server (TCPIP) on z/OS provides some samples. I had problems getting these to compile, because the JCL in the documentation was a) wrong and b) about 20 years behind times.
Samples
There are some samples in TCPIP.SEZAINST
- TCPS: a server which listens on a port
- TCPC: a client which connects to a server using IP address and port
- UDPC: C socket UDP client
- UDPS: C socket UDP server
- MTCCLNT: C socket Multitasking client
- MTCSRVR: C socket Multitasking server
- MTCCSUB: C socket subtask MTCCSUB
The JCL I used is
//COLCOMPI JOB 1,MSGCLASS=H,COND=(4,LE) //S1 JCLLIB ORDER=CBC.SCCNPRC // SET LOADLIB=COLIN.LOAD // SET LIBPRFX=CEE // SET SOURCE=COLIN.C.SOURCE(TCPSORIG) //COMPILE EXEC PROC=EDCCB, // LIBPRFX=&LIBPRFX, // CPARM='OPTFILE(DD:SYSOPTF),LSEARCH(/usr/include/)', // BPARM='SIZE=(900K,124K),RENT,LIST,RMODE=ANY,AMODE=31' //COMPILE.SYSLIB DD // DD // DD DISP=SHR,DSN=TCPIP.SEZACMAC //* DD DISP=SHR,DSN=TCPIP.SEZANMAC for IOCTL //COMPILE.SYSOPTF DD * DEF(_OE_SOCKETS) DEF(MVS) LIST,SOURCE TEST RENT ILP32 LO INFO(PAR,USE) NOMARGINS EXPMAC SHOWINC XREF LANGLVL(EXTENDED) sscom dll DEBUG /* //COMPILE.SYSIN DD DISP=SHR,DSN=&SOURCE //BIND.SYSLMOD DD DISP=SHR,DSN=&LOADLIB. //BIND.SYSLIB DD DISP=SHR,DSN=TCPIP.SEZARNT1 // DD DISP=SHR,DSN=&LIBPRFX..SCEELKED //* BIND.GSK DD DISP=SHR,DSN=SYS1.SIEALNKE //* BIND.CSS DD DISP=SHR,DSN=SYS1.CSSLIB //BIND.SYSIN DD * NAME TCPS(R) //START1 EXEC PGM=TCPS,REGION=0M, // PARM='4000 ' //STEPLIB DD DISP=SHR,DSN=&LOADLIB //SYSERR DD SYSOUT=*,DCB=(LRECL=200) //SYSOUT DD SYSOUT=*,DCB=(LRECL=200) //SYSPRINT DD SYSOUT=*,DCB=(LRECL=200)
Change the source
The samples do not compile with the above JCL. I needed to remove some includes
#include <manifest.h> // #include <bsdtypes.h> #include <socket.h> #include <in.h> // #include <netdb.h> #include <stdio.h>
With the original sample I got compiler messages
ERROR CCN3334 CEE.SCEEH.SYS.H(TYPES):66 Identifier dev_t has already been defined on line 98 of “TCPIP.SEZACMAC(BSDTYPES)”.
ERROR CCN3334 CEE.SCEEH.SYS.H(TYPES):77 Identifier gid_t has already been defined on line 101 of “TCPIP.SEZACMAC(BSDTYPES)”.
ERROR CCN3334 CEE.SCEEH.SYS.H(TYPES):162 Identifier uid_t has already been defined on line 100 of “TCPIP.SEZACMAC(BSDTYPES)”.
ERROR CCN3334 CEE.SCEEH.H(NETDB):87 Identifier in_addr has already been defined on line 158 of “TCPIP.SEZACMAC(IN)”.
INFORMATIONAL CCN3409 TCPIP.SEZAINST(TCPS):133 The static variable “ibmcopyr” is defined but never referenced.
I tried many combinations of #define but could not get it to compile, unless I removed the #includes.
Compile problems I stumbled upon
Identifier dev_t has already been defined on line ... Identifier gid_t has already been defined on line ... Identifier uid_t has already been defined on line ....
This was caused by the wrong libraries in SYSLIB. I needed
- CEE.SCEEH.H
- CEE.SCEEH.SYS.H
- TCPIP.SEZACMAC
- TCPIP.SEZANMAC
The compile problems were caused by CEE.SCEEH.SYS.H being missing.
Execution problems
I had some strange execution problem when I tried to use AT-TLS within the program.
EDC5000I No error occurred. (errno2=0x05620062)
The errno2 reason from TSO BPXMTEXT 05620062 was
BPXFSOPN 04/27/18
JRNoFileNoCreatFlag: A service tried to open a nonexistent file without O_CREATAction: The open service request cannot be processed. Correct the name or the open flags and retry the operation.
Which seems very strange. I have a feeling that this field is not properly initialised and that this value can be ignored.