z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


IP_ADD_SOURCE_MEMBERSHIP and IP_DROP_SOURCE_MEMBERSHIP

z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
SC27-3660-00

Use the IP_ADD_SOURCE_MEMBERSHIP option to join an IPv4 multicast group on an IPv4 interface and specify the IPv4 source-filter address. Set these values by using the SETSOCKOPT API and specifying the address of the IP_MREQ_SOURCE structure that contains these addresses. The application can join multiple source multicast groups on a single socket and can also join the same group on multiple interfaces on the same socket. However, there is a maximum limit of 20 groups per single UDP socket and there is a maximum limit of 256 groups per single RAW socket. The stack chooses a default multicast interface if an interface with the value 0 is passed. The format of the IP_MREQ_SOURCE structure is in the BPXYSOCK macro. The assembler program example in Figure 1 shows this socket option using the EZASMI macro:

Figure 1. IP_ADD_SOURCE_MEMBERSHIP and IP_DROP_SOURCE_MEMBERSHIP
***********************************************************************
*                                                                     *
*        Issue SETSOCKOPT - IP_ADD_SOURCE_MEMBERSHIP                  *
*                                                                     *
***********************************************************************
         MVC   IMRS_MULTIADD,MY_MULTICAST_ADDRESS
         MVC   IMRS_SOURCEADDR,MY_MULTICAST_SOURCE 
         MVC   IMRS_INTERFAC,MY_MULTICAST_INTERFACE
         EZASMI TYPE=SETSOCKOPT,  ISSUE SETSOCKOPT                     X
               S=S,               SOCKET DESCRIPTOR                    X
               OPTLEN=OPTLEN12,   OPTION LENGTH                        X
               OPTNAME='IP_ADD_SOURCE_MEMBERSHIP', OPTION NAME         X
               OPTVAL=IP_MREQ_SOURCE,    OPTION VALUE                  X
               RETCODE=RETCODE,   (SPECIFY RETCODE FIELD)              X
               ERROR=ERROR        ABEND IF MACRO ERROR
         BAL   R14,RCCHECK         --> CHECK IT
*
* Here your program will perform normal processing such as sending or
* receiving message.
*
***********************************************************************
*                                                                     *
*        Issue SETSOCKOPT - IP_DROP_SOURCE_MEMBERSHIP                 *
*                                                                     *
***********************************************************************
         MVC   IMR_MULTIADD,MY_MULTICAST_ADDRESS
         MVC   IMRS_SOURCEADDR,MY_MULTICAST_SOURCE
         MVC   IMRS_INTERFAC,MY_MULTICAST_INTERFACE
         EZASMI TYPE=SETSOCKOPT,  ISSUE SETSOCKOPT                     X
               S=S,               SOCKET DESCRIPTOR                    X
               OPTLEN=OPTLEN12,   OPTION LENGTH                        X
               OPTNAME='IP_DROP_SOURCE_MEMBERSHIP', OPTION NAME        X
               OPTVAL=IP_MREQ_SOURCE,    OPTION VALUE                  X
               RETCODE=RETCODE,   (SPECIFY RETCODE FIELD)              X
               ERROR=ERROR        ABEND IF MACRO ERROR
         BAL   R14,RCCHECK         --> CHECK IT

To remove the host from the source multicast host group you must issue a SETSOCKOPT call with the IP_DROP_SOURCE_MEMBERSHIP option. Using this call is similar to using the IP_ADD_SOURCE_MEMBERSHIP option; both use the IP_MREQ_SOURCE structure to declare the IPv4 multicast address, IPv4 source address, and the local IPv4 address interface.

While the application is a member of the source multicast host group, datagrams can be sent or received as required. To see the multicast groups that are joined on an interface, use the Netstat DEvlinks/-d command. To see the multicast groups that are joined on a socket, use the Netstat ALL/-A command.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014