⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 socketsreader.h

📁 Symbian 手机网络通信程序 sockets-vc
💻 H
字号:
/* Copyright (c) 2004, Nokia. All rights reserved */


#ifndef __SOCKETSREADER_H__
#define __SOCKETSREADER_H__

// INCLUDES
#include <in_sock.h>

// 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<KReadBufferSize> iBuffer;

        /**
        * iDummyLength, dummy - length of data read is written here.
        */
        TSockXfrLength iDummyLength;
    };

#endif // __SOCKETSREADER_H__

// End of File

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -