/** * Returns a new multicast receiver. * * @param[out] receiver Pointer to returned receiver. * @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. * @retval 0 Success. The client should call \c * mcastReceiver_free(*receiver) when the * receiver is no longer needed. * @retval EINVAL if @code{0==buf_func || 0==eof_func || * 0==missed_file_func || 0==addr} or the * multicast group address couldn't be converted * into a binary IP address. * @retval ENOMEM Out of memory. \c log_add() called. * @retval -1 Other failure. \c log_add() called. */ int mcastReceiver_new( 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) { McastReceiver* rcvr = (McastReceiver*)LOG_MALLOC(sizeof(McastReceiver), "multicast receiver"); if (0 == rcvr) return ENOMEM; try { mcastReceiver_init(rcvr, tcpAddr, tcpPort, bof_func, eof_func, missed_file_func, mcastAddr, mcastPort, obj); *receiver = rcvr; return 0; } catch (const std::invalid_argument& e) { log_add("%s", e.what()); free(rcvr); return EINVAL; } catch (const std::exception& e) { log_add("%s", e.what()); free(rcvr); return -1; } }
/** * Returns a new multicast receiver. * * @param[out] receiver Pointer to returned receiver. * @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] notifier Receiving application notifier. Freed by * `mcastReceiver_free()`. * @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] mcastIface IP address of interface for receiving multicast * packets. * @retval 0 Success. The client should call \c * mcastReceiver_free(*receiver) when the * receiver is no longer needed. * @retval EINVAL if @code{0==buf_func || 0==eof_func || * 0==missed_prod_func || 0==addr} or the * multicast group address couldn't be converted * into a binary IP address. * @retval ENOMEM Out of memory. \c log_add() called. * @retval -1 Other failure. \c log_add() called. */ int mcastReceiver_new( McastReceiver** const receiver, const char* const tcpAddr, const unsigned short tcpPort, void* const notifier, const char* const mcastAddr, const unsigned short mcastPort, const char* const mcastIface) { McastReceiver* rcvr = (McastReceiver*)log_malloc(sizeof(McastReceiver), "multicast receiver"); if (0 == rcvr) return ENOMEM; try { mcastReceiver_init(rcvr, tcpAddr, tcpPort, (RecvProxy*)notifier, mcastAddr, mcastPort, mcastIface); *receiver = rcvr; return 0; } catch (const std::invalid_argument& e) { log_add("%s", e.what()); free(rcvr); return EINVAL; } catch (const std::exception& e) { log_add("%s", e.what()); free(rcvr); return -1; } }