Click here to Skip to main content
15,881,852 members
Articles / Programming Languages / Visual C++ 10.0

SIP Stack (1 of 3)

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
20 Aug 2012CPOL3 min read 30K   1.7K   4  
SIP Stack Implementation on the basis of RFC SIP 3261 Specification
#pragma once

#ifndef CHHSocketNotifier_h
	#define CHHSocketNotifier_h

	#include <map>

	#include "CHHSocket.h"
	#include "ASyncronizationClass.h"

	namespace CoreFW
	{
		typedef std::map< int, CHHSocket* > TCHHSocketMap ;

		class CORE_DLL_DECLARATION_SPECIFIER CHHSocketNotifier
		{
		public:
			CHHSocketNotifier() ;
			virtual ~CHHSocketNotifier() ;

			FW_RETURN_TYPE Register( CHHSocket *pSocket ) ;
			FW_RETURN_TYPE Unregister( CHHSocket *pSocket ) ;

			FW_RETURN_TYPE Start( unsigned long ulTimoutPeriodInMSec ) ;
			FW_RETURN_TYPE Stop() ;
			void SetTimeoutPeriodInMSec( unsigned long ulTimoutPeriodInMSec ) ;

		private:
			static void SocketNotifierThread( void *pParam ) ;

		protected:			
			bool IsSocketSet( int iSocketHandle, fd_set *pstFDSet ) ;
			bool IsSocketClosed( int iSocketHandle ) ;

			void NotifySocketEvent( EnumSocketNotificationType eSocketNotificationType, 
												CHHSocket *pSocket, 
												const char *pstrData, int iDataLength, 
												CHHSocketException *pSocketException ) ;
		protected:
			virtual void ProcessNotification( int iNoOfSocketSetted, fd_set *pstFDSet ) = 0 ;

		protected:
			fd_set m_FDSet ;
			TCHHSocketMap m_SocketMap ;
			ASyncronizationClass *m_pSocketSyncObject ;

			unsigned long m_ulTimoutPeriodInMSec ;
			bool m_bNotifierThreadRunning ;
		} ;

		inline void CHHSocketNotifier::SetTimeoutPeriodInMSec( unsigned long ulTimoutPeriodInMSec )
		{
			m_ulTimoutPeriodInMSec = ulTimoutPeriodInMSec ;
		}

	} // End namespace

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
India India
Hatim Haidry

VC++, Technical Architect

India

haidryhatim@gmail.com

Comments and Discussions