BPX4GNM (getpeername or getsockname) example

The following code gets the peer name, and then requests the socket name. SOCKDESC was returned by a previous call to BPX4SOC. For the callable service, see getsockname or getpeername (BPX1GNM, BPX4GNM) - Get the name of a socket or connected peer. For the data structure, see BPXYSOCK — Map SOCKADDR structure and constants. AMODE 31 callers use BPX1GNM (getpeername or getsockname) example.
                                              
         SPACE ,                                                        
         CALL  BPX4GNM,                Get peername                    +
               (SOCKDESC,              Input: Socket Descriptor        +
               SOCK#GNMOPTGETPEERNAME, Input: Indicate getpeername     +
               SOCK#LEN+SOCK_SUN#LEN,  Input: Length - Sockaddr        +
               SOCKADDR,               Input: Sockaddr structure       +
               RETVAL,                 Return value: 0 or -1           +
               RETCODE,                Return code                     +
               RSNCODE),               Reason code                     +
               MF=(E,PLIST)          ---------------------------------- 
         SPACE ,                                                        
         CALL  BPX4GNM,                Get sockname                    +
               (SOCKDESC,              Input: Socket Descriptor        +
               SOCK#GNMOPTGETSOCKNAME, Input: Indicate getpeername     +
               SOCK#LEN+SOCK_SUN#LEN,  Input: Length - Sockaddr        +
               SOCKADDR,               Input: Sockaddr structure       +
               RETVAL,                 Return value: 0 or -1           +
               RETCODE,              Return code                       +
               RSNCODE),             Reason code                       +
               MF=(E,PLIST)          ----------------------------------