SASC
DVBSoftCAM

cNetWatcher Class Reference

Inheritance diagram for cNetWatcher:

List of all members.

Public Member Functions

 cNetWatcher (void)
 ~cNetWatcher ()
void Up (cNetSocket *so)
void Down (cNetSocket *so)
 cNetWatcher (void)
 ~cNetWatcher ()
void Up (cNetSocket *so)
void Down (cNetSocket *so)

Protected Member Functions

virtual void Action (void)
virtual void Action (void)

Detailed Description

Definition at line 43 of file network.c.


Constructor & Destructor Documentation

cNetWatcher::cNetWatcher ( void  )

Definition at line 57 of file network.c.

:cThread("Netwatcher")
{}
cNetWatcher::~cNetWatcher ( )

Definition at line 61 of file network.c.

References cThread::Cancel(), cSimpleListBase::Del(), cSimpleList< T >::First(), cThread::Lock(), and cThread::Unlock().

{
  Cancel(2);
  Lock();
  cNetSocket *so;
  while((so=socks.First())) socks.Del(so,false);
  Unlock();
}
cNetWatcher::cNetWatcher ( void  )
cNetWatcher::~cNetWatcher ( )

Member Function Documentation

void cNetWatcher::Action ( void  ) [protected, virtual]

A derived cThread class must implement the code it wants to execute as a separate thread in this function. If this is a loop, it must check Running() repeatedly to see whether it's time to stop.

Implements cThread.

Definition at line 85 of file network.c.

References cSimpleList< T >::First(), L_CORE_NET, cMutex::Lock(), cThread::Lock(), cSimpleList< T >::Next(), PRINTF, cThread::Running(), and cThread::Unlock().

{
  while(Running()) {
    sleep(1);
    Lock();
    for(cNetSocket *so=socks.First(); so;) {
      cNetSocket *next=socks.Next(so);
      so->Lock();
      if(so->connected && so->activity.TimedOut()) {
        PRINTF(L_CORE_NET,"idle timeout, disconnected %s:%d",so->hostname,so->port);
        so->Disconnect();
        }
      so->Unlock();
      so=next;
      }
    Unlock();
    }
}
virtual void cNetWatcher::Action ( void  ) [protected, virtual]

A derived cThread class must implement the code it wants to execute as a separate thread in this function. If this is a loop, it must check Running() repeatedly to see whether it's time to stop.

Implements cThread.

void cNetWatcher::Down ( cNetSocket *  so)
void cNetWatcher::Down ( cNetSocket *  so)

Definition at line 78 of file network.c.

References cSimpleListBase::Del(), cThread::Lock(), and cThread::Unlock().

Referenced by cNetSocket::Disconnect().

{
  Lock();
  socks.Del(so,false);
  Unlock();
}
void cNetWatcher::Up ( cNetSocket *  so)

Definition at line 70 of file network.c.

References cThread::Active(), cSimpleListBase::Add(), cThread::Lock(), cThread::Start(), and cThread::Unlock().

Referenced by cNetSocket::Bind(), and cNetSocket::Connect().

{
  Lock();
  socks.Add(so);
  if(!Active()) Start();
  Unlock();
}
void cNetWatcher::Up ( cNetSocket *  so)

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines