Refactor out an unnecessary socket parameter.

This commit is contained in:
Antti Seppälä 2007-10-21 19:32:14 +00:00
parent eebd990991
commit e1c4d22fda
5 changed files with 23 additions and 9 deletions

View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: protocolext.c,v 1.19 2007/10/21 17:32:43 ajhseppa Exp $ * $Id: protocolext.c,v 1.20 2007/10/21 19:32:14 ajhseppa Exp $
*/ */
#include <sys/wait.h> #include <sys/wait.h>
@ -117,7 +117,7 @@ bool cIptvProtocolExt::Open(void)
if (!strlen(scriptFile)) if (!strlen(scriptFile))
return false; return false;
// Create the listening socket // Create the listening socket
OpenSocket(socketPort, true); OpenSocket(socketPort);
// Execute the external script // Execute the external script
ExecuteScript(); ExecuteScript();
isActive = true; isActive = true;

View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: protocolhttp.c,v 1.19 2007/10/21 17:32:43 ajhseppa Exp $ * $Id: protocolhttp.c,v 1.20 2007/10/21 19:32:14 ajhseppa Exp $
*/ */
#include <sys/types.h> #include <sys/types.h>
@ -43,7 +43,7 @@ bool cIptvProtocolHttp::Connect(void)
// Check that stream address is valid // Check that stream address is valid
if (!isActive && !isempty(streamAddr) && !isempty(streamPath)) { if (!isActive && !isempty(streamAddr) && !isempty(streamPath)) {
// Ensure that socket is valid // Ensure that socket is valid
OpenSocket(socketPort, false); OpenSocket(socketPort);
// First try only the IP address // First try only the IP address
sockAddr.sin_addr.s_addr = inet_addr(streamAddr); sockAddr.sin_addr.s_addr = inet_addr(streamAddr);

View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: protocoludp.c,v 1.20 2007/10/21 17:32:43 ajhseppa Exp $ * $Id: protocoludp.c,v 1.21 2007/10/21 19:32:15 ajhseppa Exp $
*/ */
#include <sys/types.h> #include <sys/types.h>
@ -40,7 +40,7 @@ bool cIptvProtocolUdp::JoinMulticast(void)
// Check that stream address is valid // Check that stream address is valid
if (!isActive && !isempty(streamAddr)) { if (!isActive && !isempty(streamAddr)) {
// Ensure that socket is valid // Ensure that socket is valid
OpenSocket(socketPort, true); OpenSocket(socketPort);
// Join a new multicast group // Join a new multicast group
struct ip_mreq mreq; struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = inet_addr(streamAddr); mreq.imr_multiaddr.s_addr = inet_addr(streamAddr);
@ -60,7 +60,7 @@ bool cIptvProtocolUdp::DropMulticast(void)
// Check that stream address is valid // Check that stream address is valid
if (isActive && !isempty(streamAddr)) { if (isActive && !isempty(streamAddr)) {
// Ensure that socket is valid // Ensure that socket is valid
OpenSocket(socketPort, true); OpenSocket(socketPort);
// Drop the multicast group // Drop the multicast group
struct ip_mreq mreq; struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = inet_addr(streamAddr); mreq.imr_multiaddr.s_addr = inet_addr(streamAddr);

View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: socket.c,v 1.3 2007/10/21 17:32:43 ajhseppa Exp $ * $Id: socket.c,v 1.4 2007/10/21 19:32:15 ajhseppa Exp $
*/ */
#include <sys/types.h> #include <sys/types.h>
@ -99,6 +99,12 @@ cIptvUdpSocket::~cIptvUdpSocket()
debug("cIptvUdpSocket::~cIptvUdpSocket()\n"); debug("cIptvUdpSocket::~cIptvUdpSocket()\n");
} }
bool cIptvUdpSocket::OpenSocket(const int Port)
{
debug("cIptvUdpSocket::OpenSocket()\n");
return cIptvSocket::OpenSocket(Port, true);
}
int cIptvUdpSocket::Read(unsigned char* *BufferAddr) int cIptvUdpSocket::Read(unsigned char* *BufferAddr)
{ {
//debug("cIptvUdpSocket::Read()\n"); //debug("cIptvUdpSocket::Read()\n");
@ -170,6 +176,12 @@ cIptvTcpSocket::~cIptvTcpSocket()
debug("cIptvTcpSocket::~cIptvTcpSocket()\n"); debug("cIptvTcpSocket::~cIptvTcpSocket()\n");
} }
bool cIptvTcpSocket::OpenSocket(const int Port)
{
debug("cIptvTcpSocket::OpenSocket()\n");
return cIptvSocket::OpenSocket(Port, false);
}
int cIptvTcpSocket::Read(unsigned char* *BufferAddr) int cIptvTcpSocket::Read(unsigned char* *BufferAddr)
{ {
//debug("cIptvTcpSocket::Read()\n"); //debug("cIptvTcpSocket::Read()\n");

View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: socket.h,v 1.2 2007/10/21 17:32:43 ajhseppa Exp $ * $Id: socket.h,v 1.3 2007/10/21 19:32:15 ajhseppa Exp $
*/ */
#ifndef __IPTV_SOCKET_H #ifndef __IPTV_SOCKET_H
@ -34,6 +34,7 @@ public:
cIptvUdpSocket(); cIptvUdpSocket();
virtual ~cIptvUdpSocket(); virtual ~cIptvUdpSocket();
virtual int Read(unsigned char* *BufferAddr); virtual int Read(unsigned char* *BufferAddr);
bool OpenSocket(const int Port);
}; };
class cIptvTcpSocket : public cIptvSocket { class cIptvTcpSocket : public cIptvSocket {
@ -41,6 +42,7 @@ public:
cIptvTcpSocket(); cIptvTcpSocket();
virtual ~cIptvTcpSocket(); virtual ~cIptvTcpSocket();
virtual int Read(unsigned char* *BufferAddr); virtual int Read(unsigned char* *BufferAddr);
bool OpenSocket(const int Port);
}; };
#endif // __IPTV_SOCKET_H #endif // __IPTV_SOCKET_H