www.pudn.com > sockets.rar > socketsreader.h
/* Copyright (c) 2004, Nokia. All rights reserved */ #ifndef __SOCKETSREADER_H__ #define __SOCKETSREADER_H__ // INCLUDES #include// FORWARD DECLARATIONS class MEngineNotifier; // CLASS DECLARATION /** * CSocketsReader * This class handles reading data from the socket. * In this implementation, any data read is simply displayed * as text on the console. */ class CSocketsReader : public CActive { public: // Constructors and destructors /** * NewL. * Two-phased constructor. * Creates a CSocketsReader object using two phase construction, * and returns a pointer to the created object. * @param aEngineNotifier An observer for status reporting. * @param aSocket Socket to read from. * @return A pointer to the created instance of CSocketsReader. */ static CSocketsReader* NewL( MEngineNotifier& aEngineNotifier, RSocket& aSocket ); /** * NewLC. * Two-phased constructor. * Creates a CSocketsReader object using two phase construction, * and returns a pointer to the created object. * @param aEngineNotifier An observer for status reporting. * @param aSocket Socket to read from. * @return A pointer to the created instance of CSocketsReader. */ static CSocketsReader* NewLC( MEngineNotifier& aEngineNotifier, RSocket& aSocket ); /** * ~CSocketsReader. * Destructor. * Destroys the object and release all memory objects. */ virtual ~CSocketsReader(); public: // New functions /** * Start. * Initiates a read from socket. */ void Start(); protected: // Functions from base classes /** * From CActive, DoCancel. * Cancels any outstanding operation. */ void DoCancel(); /** * From CActive, RunL. * Called when operation completes. */ void RunL(); private: // Constructors and destructors /** * CSocketsReader. * C++ default constructor. * Performs the first phase of two phase construction. * @param aEngineNotifier An observer for status reporting. * @param aSocket Socket to read from. */ CSocketsReader( MEngineNotifier& aEngineNotifier, RSocket& aSocket ); /** * ConstructL. * 2nd phase constructor. */ void ConstructL(); private: // New functions /** * IssueRead. * Initiates a read from socket. */ void IssueRead(); private: // Constants /** * KReadBufferSize, the size of the read buffer in bytes. */ enum { KReadBufferSize = 20 }; private: // Data /** * iSocket, Socket to read data from. */ RSocket& iSocket; /** * iEngineNotifier, An observer for status reporting. */ MEngineNotifier& iEngineNotifier; /** * iBuffer, Buffer for receiving data. */ TBuf8 iBuffer; /** * iDummyLength, dummy - length of data read is written here. */ TSockXfrLength iDummyLength; }; #endif // __SOCKETSREADER_H__ // End of File