/** * Initializes a multicast receiver. * * @param[out] receiver The receiver to initialize. * @param[in] tcpAddr Address of the TCP server from which to * retrieve missed data-blocks. May be * hostname or IP address. * @param[in] tcpPort Port number of the TCP server to which to * connect. * @param[in] bof_func Function to call when the multicast layer * has seen a beginning-of-file. * @param[in] eof_func Function to call when the multicast layer * has completely received a file. * @param[in] missed_file_func Function to call when a file is missed * by the multicast layer. * @param[in] mcastAddr Address of the multicast group to receive. * May be groupname or formatted IP address. * @param[in] mcastPort Port number of the multicast group. * @param[in] obj Relevant object in the receiving * application to pass to the above * functions. May be NULL. * @throws std::invalid_argument if @code{0==buf_func || 0==eof_func || * 0==missed_file_func || 0==addr}. * @throws std::invalid_argument if the multicast group address couldn't be * converted into a binary IPv4 address. * @throws std::runtime_error if the IP address of the PA interface * couldn't be obtained. (The PA address * seems to be specific to Linux and might * cause problems.) * @throws std::runtime_error if the socket couldn't be bound to the * interface. * @throws std::runtime_error if the socket couldn't be bound to the * Internet address. * @throws std::runtime_error if the multicast group couldn't be * added to the socket. * @throws std::exception If the multicast receiver can't be * initialized. */ static void mcastReceiver_init( McastReceiver* const receiver, const char* const tcpAddr, const unsigned short tcpPort, const BofFunc bof_func, const EofFunc eof_func, const MissedFileFunc missed_file_func, const char* const mcastAddr, const unsigned short mcastPort, void* const obj) { std:string hostId(tcpAddr); VCMTPReceiver* rcvr = new VCMTPReceiver(hostId, tcpPort, PerFileNotifier(bof_func, eof_func, missed_file_func, obj)); try { rcvr->JoinGroup(std::string(mcastAddr), mcastPort); receiver->receiver = rcvr; } catch (const std::exception& e) { delete rcvr; throw; } /* "rcvr" allocated */ }
/** * Initializes a multicast receiver. * * @param[out] receiver The receiver to initialize. * @param[in] hostId Address of the TCP server from which to * retrieve missed data-blocks. May be * hostname or IPv4 address. * @param[in] tcpPort Port number of the TCP server to which to * connect. * @param[in] notifier Receiving application notifier. Freed by * `mcastReceiver_free()`. * @param[in] mcastAddr Address of the multicast group to receive. * May be groupname or IPv4 address. * @param[in] mcastPort Port number of the multicast group. * @param[in] mcastIface IP address of interface for receiving * multicast packets. * @throws std::invalid_argument if @code{0==buf_func || 0==eof_func || * 0==missed_prod_func || 0==addr}. * @throws std::invalid_argument if the multicast group address couldn't be * converted into a binary IPv4 address. * @throws std::runtime_error if the IP address of the PA interface * couldn't be obtained. (The PA address * seems to be specific to Linux and might * cause problems.) * @throws std::runtime_error if the socket couldn't be bound to the * interface. * @throws std::runtime_error if the socket couldn't be bound to the * Internet address. * @throws std::runtime_error if the multicast group couldn't be * added to the socket. * @throws std::exception If the multicast receiver can't be * initialized. */ static void mcastReceiver_init( McastReceiver* const receiver, const char* const tcpAddr, const unsigned short tcpPort, RecvProxy* const notifier, const char* const mcastAddr, const unsigned short mcastPort, const char* const mcastIface) { std::string hostId(tcpAddr); std::string groupId(mcastAddr); receiver->notifier = notifier; receiver->fmtpReceiver = new fmtpRecvv3(hostId, tcpPort, groupId, mcastPort, notifier, mcastIface); }
/** * Initializes a multicast receiver. * * @param[out] receiver The receiver to initialize. * @param[in] hostId Address of the TCP server from which to * retrieve missed data-blocks. May be * hostname or IP address. * @param[in] tcpPort Port number of the TCP server to which to * connect. * @param[in] bop_func Function to call when the multicast layer * has seen a beginning-of-product. * @param[in] eop_func Function to call when the multicast layer * has completely received a product. * @param[in] missed_prod_func Function to call when a product is missed * by the multicast layer. * @param[in] mcastAddr Address of the multicast group to receive. * May be groupname or formatted IP address. * @param[in] mcastPort Port number of the multicast group. * @param[in] obj Relevant object in the receiving * application to pass to the above * functions. May be NULL. * @throws std::invalid_argument if @code{0==buf_func || 0==eof_func || * 0==missed_prod_func || 0==addr}. * @throws std::invalid_argument if the multicast group address couldn't be * converted into a binary IPv4 address. * @throws std::runtime_error if the IP address of the PA interface * couldn't be obtained. (The PA address * seems to be specific to Linux and might * cause problems.) * @throws std::runtime_error if the socket couldn't be bound to the * interface. * @throws std::runtime_error if the socket couldn't be bound to the * Internet address. * @throws std::runtime_error if the multicast group couldn't be * added to the socket. * @throws std::exception If the multicast receiver can't be * initialized. */ static void mcastReceiver_init( McastReceiver* const receiver, const char* const tcpAddr, const unsigned short tcpPort, const BopFunc bop_func, const EopFunc eop_func, const MissedProdFunc missed_prod_func, const char* const mcastAddr, const unsigned short mcastPort, void* const obj) { std::string hostId(tcpAddr); std::string groupId(mcastAddr); // Following object will be deleted by `vcmtpRecvv3` destructor receiver->notifier = new PerProdNotifier(bop_func, eop_func, missed_prod_func, obj); vcmtpRecvv3* rcvr = new vcmtpRecvv3(hostId, tcpPort, groupId, mcastPort, receiver->notifier); }