MCPcopy Create free account
hub / github.com/Hamlib/Hamlib / network_multicast_receiver_start

Function network_multicast_receiver_start

src/network.c:1790–1892  ·  view source on GitHub ↗

* \brief Start multicast receiver * * Start multicast receiver. * * \param multicast_addr UDP address * \param multicast_port UDP socket port * \return RIG_OK or < 0 if error */

Source from the content-addressed store, hash-verified

1788 * \return RIG_OK or < 0 if error
1789 */
1790int network_multicast_receiver_start(RIG *rig, const char *multicast_addr,
1791 int multicast_port)
1792{
1793 struct rig_state *rs = STATE(rig);
1794 multicast_receiver_priv_data *mcast_receiver_priv;
1795 int socket_fd;
1796 int status;
1797
1798 ENTERFUNC;
1799
1800 if (rs->multicast_receiver_priv_data != NULL)
1801 {
1802 rig_debug(RIG_DEBUG_ERR, "%s(%d): multicast receiver already running\n",
1803 __FILE__,
1804 __LINE__);
1805 RETURNFUNC(-RIG_EINVAL);
1806 }
1807
1808 rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): multicast receiver address=%s, port=%d\n",
1809 __FILE__,
1810 __LINE__,
1811 multicast_addr, multicast_port);
1812
1813 if (multicast_addr == NULL || strcmp(multicast_addr, "0.0.0.0") == 0)
1814 {
1815 rig_debug(RIG_DEBUG_TRACE, "%s(%d): not starting multicast receiver\n",
1816 __FILE__, __LINE__);
1817 RETURNFUNC(RIG_OK);
1818 }
1819
1820 status = network_init();
1821
1822 if (status != RIG_OK)
1823 {
1824 RETURNFUNC(status);
1825 }
1826
1827 socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
1828
1829 if (socket_fd < 0)
1830 {
1831 rig_debug(RIG_DEBUG_ERR, "%s: error opening new UDP socket: %s", __func__,
1832 strerror(errno));
1833 RETURNFUNC(-RIG_EIO);
1834 }
1835
1836 // Enable non-blocking mode
1837 u_long mode = 1;
1838#ifdef __MINGW32__
1839
1840 if (ioctlsocket(socket_fd, FIONBIO, &mode) == SOCKET_ERROR)
1841 {
1842 rig_debug(RIG_DEBUG_ERR, "%s: error enabling non-blocking mode for socket: %s",
1843 __func__,
1844 strerror(errno));
1845 RETURNFUNC(-RIG_EIO);
1846 }
1847

Callers 1

rig_openFunction · 0.85

Calls 3

rig_debugFunction · 0.85
network_initFunction · 0.85
pthread_createFunction · 0.85

Tested by

no test coverage detected