1
0
mirror of https://github.com/rofafor/vdr-plugin-satip.git synced 2023-10-10 13:37:42 +02:00

Re-enable to reuse address for msearch protocol.

This commit is contained in:
Rolf Ahrenberg 2016-04-11 23:02:12 +03:00
parent 9d7c745fe1
commit 8222d05f5d
3 changed files with 8 additions and 4 deletions

View File

@ -29,7 +29,7 @@ cSatipMsearch::cSatipMsearch(cSatipDiscoverIf &discoverP)
memset(bufferM, 0, bufferLenM);
else
error("Cannot create Msearch buffer!");
if (!Open(eDiscoveryPort))
if (!Open(eDiscoveryPort, true))
error("Cannot open Msearch port!");
}

View File

@ -34,10 +34,11 @@ cSatipSocket::~cSatipSocket()
Close();
}
bool cSatipSocket::Open(const int portP, const bool reuseAddrP)
bool cSatipSocket::Open(const int portP, const bool reuseP)
{
// Bind to the socket if it is not active already
if (socketDescM < 0) {
int yes;
socklen_t len = sizeof(sockAddrM);
// Create socket
socketDescM = socket(PF_INET, SOCK_DGRAM, 0);
@ -46,9 +47,12 @@ bool cSatipSocket::Open(const int portP, const bool reuseAddrP)
ERROR_IF_FUNC(fcntl(socketDescM, F_SETFL, O_NONBLOCK), "fcntl(O_NONBLOCK)",
Close(), return false);
// Allow multiple sockets to use the same PORT number
int yes = reuseAddrP;
yes = reuseP;
ERROR_IF_FUNC(setsockopt(socketDescM, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0,
"setsockopt(SO_REUSEADDR)", Close(), return false);
yes = reuseP;
ERROR_IF_FUNC(setsockopt(socketDescM, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(yes)) < 0 && errno != ENOPROTOOPT,
"setsockopt(SO_REUSEPORT)", Close(), return false);
// Bind socket
memset(&sockAddrM, 0, sizeof(sockAddrM));
sockAddrM.sin_family = AF_INET;

View File

@ -19,7 +19,7 @@ private:
public:
cSatipSocket();
virtual ~cSatipSocket();
bool Open(const int portP = 0, const bool reuseAddrP = false);
bool Open(const int portP = 0, const bool reuseP = false);
virtual void Close(void);
int Fd(void) { return socketDescM; }
int Port(void) { return socketPortM; }