📄 tcpipmultihomingexengine.h
字号:
#ifndef __TcpipMultiHomingExENGINE_H__
#define __TcpipMultiHomingExENGINE_H__
#include <in_sock.h>
#include "TcpipMultiHomingExTimer.h"
class CTcpipMultiHomingExAppUi;
class RConnection;
class CTcpipMultiHomingExTimer;
const TInt KMaxServerNameLength = 50;
const TInt KReadBufferSize = 50;
class MTcpipMultiHomingExEngineObserver
{
public:
virtual void ErrorL(const TDesC& aErrMessage, TInt aErrCode) = 0;
virtual void ResponseReceivedL(const TDesC& aMessage) = 0;
virtual void SetStatus(const TDesC& aStatus) = 0;
};
/**
*
* @class CTcpipMultiHomingExEngine TcpipMultiHomingExEngine.h
* @brief This class is resposible for making a TCP/IP connection
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*
*/
class CTcpipMultiHomingExEngine : public CActive, public MTimeOutNotifier
{
public:
/*!
@enum TErrorType
@discussion Error types encountered when reading/writing to a sockets
@value EDisconnected A disconnected error has been encountered
@value ETimeOutOnWrite A write operation has failed to complete within a predetermined period
@value EGeneralReadError A general error has been encountered during a read
@value EGeneralWriteError A general error has been encountered during a write
*/
enum TErrorType
{
EDisconnected,
EGeneralReadError,
EDNSLookupFailed,
EConnectionFailed,
ETimedOut
};
public: // new methods
/*!
@function NewL
@discussion Create a CTcpipMultiHomingExEngine object
@param aConsole console to use for ui output
@result a pointer to the created instance of CTcpipMultiHomingExEngine
*/
static CTcpipMultiHomingExEngine* NewL(MTcpipMultiHomingExEngineObserver& aObserver);
/*!
@function NewLC
@discussion Create a CTcpipMultiHomingExEngine object
@param aConsole console to use for ui output
@result a pointer to the created instance of CTcpipMultiHomingExEngine
*/
static CTcpipMultiHomingExEngine* NewLC(MTcpipMultiHomingExEngineObserver& aObserver);
/*!
@function ~CTcpipMultiHomingExEngine
@discussion Destroy the object and release all memory objects
*/
~CTcpipMultiHomingExEngine();
/*!
@function ConnectL
@discussion Initiate connection of socket, using iServerName and iPort
*/
void ConnectL();
/*!
@function Disconnect
@discussion Disconnect socket
*/
void Disconnect();
/*!
@function Read
@discussion Initiate read of data from socket
void Read();
*/
public: // from MTimeOutNotifier
/*!
@function TimerExpired
@discussion The function to be called when a timeout occurs
*/
void TimerExpiredL();
public:
/*!
@function ReportError
@discussion Report a communication error
@param aErrorType error type
@param aErrorCode associated error code
*/
void ReportErrorL(TErrorType aErrorType, TInt aErrorCode);
/*!
@function ResponseReceived
@discussion Data has been received on the socket and read into a buffer
@param aBuffer the data buffer
void ResponseReceived(const TDesC8& aBuffer);
*/
protected: // from CActive
/*!
@function DoCancel
@discussion cancel any outstanding operation
*/
void DoCancel();
/*!
@function RunL
@discussion called when operation complete
*/
void RunL();
private: // New methods
/*!
@function CTcpipMultiHomingExEngine
@discussion Perform the first phase of two phase construction
@param aConsole the console to use for ui output
*/
CTcpipMultiHomingExEngine(MTcpipMultiHomingExEngineObserver& aObserver);
/*!
@function ConstructL
@discussion Perform the second phase construction of a CTcpipMultiHomingExEngine
*/
void ConstructL();
/*!
@function ConnectL
@discussion initiate a connect operation on a socket
@param aAddr the ip address to connect to
*/
void ConnectL(TUint32 aAddr);
void Read();
/*!
@enum TSocketsEngineState
@discussion Tracks the state of this object through the connection process
@value ENotConnected The initial (idle) state
@value EConnecting A connect request is pending with the socket server
@value EConnected A connection has been established
@value ELookingUp A DNS lookup request is pending with the socket server
*/
enum TEngineState
{
ENotConnected,
ERConnStarting,
EConnecting,
EConnected,
ELookingUp,
EReading,
EDestroyed
};
/*!
@function ChangeStatus
@discussion handle a change in this object's status
@param aNewStatus new status
*/
void ChangeStatus(TEngineState aNewStatus);
/*!
@function Print
@discussion display text on the console
@param aDes text to display
void Print(const TDesC& aDes);
*/
private: // Member variables
/*! @var this object's current status */
TEngineState iEngineStatus;
/*! @var observer */
MTcpipMultiHomingExEngineObserver& iObserver;
/*! @var the actual socket */
RSocket iSocket;
RConnection iRConn;
/*! @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 */
CTcpipMultiHomingExTimer* 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;
/*! @var buffer for receiving data */
TBuf8<KReadBufferSize> iBuffer;
/*! @var dummy - length of data read is written here */
TSockXfrLength iLength;
};
#endif // __TcpipMultiHomingExENGINE_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -