mirror of
				https://github.com/rofafor/vdr-plugin-satip.git
				synced 2023-10-10 11:37:42 +00:00 
			
		
		
		
	Re-enable to reuse address for msearch protocol.
This commit is contained in:
		@@ -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!");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										8
									
								
								socket.c
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								socket.c
									
									
									
									
									
								
							@@ -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;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								socket.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								socket.h
									
									
									
									
									
								
							@@ -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; }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user