📄 socketsengine.h
字号:
/* Copyright (c) 2001, Nokia. All rights reserved */
#ifndef __SOCKETSENGINE_H__
#define __SOCKETSENGINE_H__
#include <in_sock.h>
#ifndef __WINS__
#include <es_sock.h> // RConnection
#endif
#include "TimeOutNotifier.h"
#include "EngineNotifier.h"
#include "Sockets.hrh"
class CSocketsReader;
class CSocketsWriter;
class CTimeOutTimer;
class MUINotifier;
#ifndef HTTP_DOWN_CMWAP
#define HTTP_DOWN_CMWAP 0
#define HTTP_DOWN_CMNET 1
#endif
class CSocketsEngine : public CActive, public MTimeOutNotifier, public MEngineNotifier
{
public: // new methods
static CSocketsEngine* NewL(MUINotifier& aConsole, TInt down_type);
static CSocketsEngine* NewLC(MUINotifier& aConsole, TInt down_type);
~CSocketsEngine();
void ConnectL();
void Disconnect();
void WriteL(const TDesC8& aData);
void Read();
void SetServerName(const TDesC& aName);
const TDesC& ServerName() const;
void SetPort(TInt aPort);
TInt Port() const;
TBool Connected() const;
public: // from MTimeOutNotifier
void TimerExpired();
public: // from MEngineNotifier
void ReportError(MEngineNotifier::TErrorType aErrorType, TInt aErrorCode);
void ResponseReceived(const TDesC8& aBuffer);
protected: // from CActive
void DoCancel();
void RunL();
private: // New methods
CSocketsEngine(MUINotifier& aConsole);
void ConstructL(TInt down_type);
TUint32 CreateCmnetIap() ;
TUint32 CreateCmwapIap() ;
void ConnectSmoothCMNET() ;
void ConnectSmoothCMWAP() ;
void ConnectL(TUint32 aAddr);
enum TSocketsEngineState
{
ENotConnected,
EConnecting,
EConnected,
ELookingUp
};
void ChangeStatus(TSocketsEngineState aNewStatus);
void Print(const TDesC& aDes);
private: // Member variables
/*! @const The maximum time allowed for a lookup or connect requests to complete */
static const TInt KTimeOut;
/*! @const The initial port number displayed to the user */
static const TInt KDefaultPortNumber;
/*! @var this object's current status */
TSocketsEngineState iEngineStatus;
/*! @var console for displaying text etc */
MUINotifier& iConsole;
/*! @var the actual socket */
RSocket iSocket;
/*! @var active object to control reads from the socket */
CSocketsReader* iSocketsReader;
/*! @var active object to control writes to the socket */
CSocketsWriter* iSocketsWriter;
#ifndef __WINS__
/*! @var the connection management */
RConnection iConn ;
#endif
/*! @var the socket server */
RSocketServ iSocketServ;
/*! @var DNS name resolver */
RHostResolver iResolver;
/*! @var The result from the name resolver */
TNameEntry iNameEntry;
/*! @var The anme record found by the resolver */
TNameRecord iNameRecord;
/*! @var timer active object */
CTimeOutTimer* iTimer;
/*! @var The address to be used in the connection */
TInetAddr iAddress;
/*! @var port number to connect to */
TInt iPort;
/*! @var server name to connect to */
TBuf<KMaxServerNameLength> iServerName;
};
#endif // __SOCKETSENGINE_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -