# HG changeset patch # User John Calcote # Date 1491590497 21600 # Fri Apr 07 12:41:37 2017 -0600 # Node ID 5f989105ddc62829adbb3ac1c36a51bd927ba1d9 # Parent 2faa881f0616fce98cf239e80989cd650347190d BUG#139: Change default slpreg connection from UDP to TCP. diff -r 2faa881f0616 -r 5f989105ddc6 libslp/libslp_network.c --- a/libslp/libslp_network.c Fri Apr 07 12:25:06 2017 -0600 +++ b/libslp/libslp_network.c Fri Apr 07 12:41:37 2017 -0600 @@ -371,21 +371,29 @@ { sockfd_t sock = SLP_INVALID_SOCKET; - /*Note that these don't actually test the connection to slpd. - They don't have to, since all code that calls this function eventually - does a NetworkRqstRply, which has retry logic for the datagram case*/ + /* Note that these don't actually test the connection to slpd. + * They don't have to, since all code that calls this function eventually + * does a NetworkRqstRply, which has retry logic for the datagram case. + */ + struct timeval timeout; + timeout.tv_sec = SLPPropertyAsInteger(SLPGetProperty("net.slp.randomWaitBound")); + timeout.tv_usec = (timeout.tv_sec % 1000) * 1000; + timeout.tv_sec = timeout.tv_sec / 1000; if (SLPNetIsIPV6()) - if (!SLPNetSetAddr(peeraddr, AF_INET6, (uint16_t)SLPPropertyAsInteger("net.slp.port"), + if (!SLPNetSetAddr(peeraddr, AF_INET6, + (uint16_t)SLPPropertyAsInteger("net.slp.port"), &slp_in6addr_loopback)) - sock = SLPNetworkCreateDatagram(AF_INET6); + sock = SLPNetworkConnectStream(peeraddr, &timeout); if (sock == SLP_INVALID_SOCKET && SLPNetIsIPV4()) { int tempAddr = INADDR_LOOPBACK; if (SLPNetSetAddr(peeraddr, AF_INET, (uint16_t)SLPPropertyAsInteger("net.slp.port"), &tempAddr) == 0) - sock = SLPNetworkCreateDatagram(AF_INET); + { + sock = SLPNetworkConnectStream(peeraddr, &timeout); + } } return sock; }