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

📄 tcpexactive.h

📁 关于symbian uiq平台的例子不多
💻 H
字号:
//
// Example of using TCP/IP with Rsocket interface
//
// Will retrieve a Web page the hard way by resolving the IP addess of
// a server, constructing a HTTP: request, sending it to the server,
// and then receiving the response

#include <es_sock.h>
#include <in_sock.h>

static const TInt
	KServerNameStartPos = 7 ,
	KMaxServerNameLength = 50 ,
	KMaxResourceNameLength = 50 ,
	KMaxRequestLength = 50 ,
	KReceiveChunkSize = 250 ,
	KResponseLength = 4000 ;

enum TRetrieveHttpProgress 
	{
	EIdle,
	EResolving,
	EConnecting,
	ESending,
	EReceiving,
	EComplete,
	EFailed,
	} ;
	


// A 'Mixin' - an abstract base class which classes that will make use of CRetrieveHttp will derive from,
// basically a way of registering callback functions...
class MRetrieveHttpCallbacks
{
public:
	// Pure virtual implemented by classes which inherit from MRetrieveHttpCallback to
	// pick up (and act on) changes of state.  
	virtual void StateChange(TRetrieveHttpProgress aState) = 0 ;
} ;


// A class which can perform an HTTP: "GET" operation.
class CRetrieveHttp : public CActive
	{
public:
	// Usual two-phase construction stuff... 
	static CRetrieveHttp* NewL(MRetrieveHttpCallbacks& aCallback);
	static CRetrieveHttp* NewLC(MRetrieveHttpCallbacks& aCallback);
	~CRetrieveHttp();

	// The usual active object stuff - every Active Object _must_ implement RunL, DoCancel, 
	// and a request method of some description 
	void RunL() ;
	void DoCancel() ;
	void RequestL(const TDesC& aURL) ;

	// Access method to get at the retrieved data
	TDesC &GetResponseData() ;

private:
	// Usual two-phase construction stuff... 
	void ConstructL(); 
	// Standard C++ constructor/destructor
	CRetrieveHttp(MRetrieveHttpCallbacks& aCallback) ; 	

	// Various bits of the URL
	TBuf<KMaxServerNameLength> iServerName;

	// The HTTP request
	TBuf8<KMaxRequestLength> iRequest ;
	
	// Response data
	TBuf8<KReceiveChunkSize> iResponseChunk ;
	TBuf<KResponseLength> iResponse ;		
		
	// Sockety stuff and IP address
	RSocketServ iSockServer ;
	RHostResolver iResolver ;
	RSocket iSocket ;
	TNameEntry iHostAddress ;
	TSockXfrLength iResponseChunkSizePkg ;
	
	// Sundry state and status bits
	TRetrieveHttpProgress iState ;
	
	// Progress callback 
	MRetrieveHttpCallbacks& iCallbacks ;
} ;

⌨️ 快捷键说明

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