socketsreader.h

来自「NOKIA手机的基于C++的socket完整的开发API,非常好用」· C头文件 代码 · 共 112 行

H
112
字号
/* Copyright (c) 2001, Nokia Mobile Phones. All rights reserved */

#ifndef __SOCKETSREADER_H__
#define __SOCKETSREADER_H__

#include <in_sock.h>

class MEngineNotifier;

/*! 
  @class CSocketsReader
  
  @discussion 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:
/*!
  @function NewL
   
  @discussion Create a CSocketsReader object
  @param aEngineNotifier An observer for status reporting
  @param aSocket socket to read from
  @result a pointer to the created instance of CSocketsReader
  */
	static CSocketsReader* NewL(MEngineNotifier& aEngineNotifier, RSocket& aSocket);

/*!
  @function NewLC
   
  @discussion Create a CSocketsReader object
  @param aEngineNotifier An observer for status reporting
  @param aSocket socket to read from
  @result a pointer to the created instance of CSocketsReader
  */
    static CSocketsReader* NewLC(MEngineNotifier& aEngineNotifier, RSocket& aSocket);

/*!
  @function ~CSocketsReader
  
  @discussion Destroy the object and release all memory objects
  */
	~CSocketsReader();

/*!
  @function Start

  @discussion Initiate a read from socket
  */
	void Start();

protected: // from CActive
/*!
  @function DoCancel
   
  @discussion cancel any outstanding operation
  */
	void DoCancel();

/*!
  @function RunL
   
  @discussion called when operation complete
  */
	void RunL();	

private:
/*!
  @function CSocketsReader
  
  @discussion Perform 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);

/*!
  @function ConstructL
  
  @discussion Perform the second phase construction of a CSocketsReader 
  */
	void ConstructL();

/*!
  @function IssueRead

  @discussion Initiate a read from socket
  */
	void IssueRead();

private: // Member variables

    /*! @const The size of the read buffer in bytes */
    enum {KReadBufferSize = 20};

    /*! @var socket to read data from */
    RSocket&                iSocket;

    /*! @var An observer for status reporting */
	MEngineNotifier&        iEngineNotifier;

    /*! @var buffer for receiving data */
	TBuf8<KReadBufferSize>  iBuffer;

    /*! @var dummy - length of data read is written here */
    TSockXfrLength          iDummyLength;
    };

#endif // __SOCKETSREADER_H__

⌨️ 快捷键说明

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