Plz help me
My code:
#include <e32base.h>
#include <e32cons.h>
#include <in_sock.h>
LOCAL_D CConsoleBase* console;
class CModel : public CActive {
public:
CModel();
void StartEngineL(void);
TRequestStatus status;
private:
void RunL(void);
void DoCancel (void);
void AcceptNextConnectionL();
private:
RSocketServ lSession;
RSocket lListenSocket, lSocket;
// CRx* iRxAO; // Receiver active object
// CTx* iTxAO; // Transmitter active object
};
CModel::CModel():CActive(0)
{
console->Printf(_L("\na constructed"😉);
}
void CModel:😃oCancel()
{
CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; // get active scheduler
CleanupStack::PushL(scheduler);
CActiveScheduler::Install(scheduler);
CActiveScheduler::Add(this);
}
void CModel::AcceptNextConnectionL()
{
lListenSocket.Accept(lSocket, status);
console->Printf(_L("accept called\n "😉);
SetActive();
console->Printf(_L("setactive called\n "😉);
}
void CModel::StartEngineL (void)
{
_LIT(KSockText,"TCP Socket Testing!"😉;
console->Printf(KSockText);
//RSocketServ lSession;
//RSocket lListenSocket, lSocket;
TInt lErr;
// Connect to the socket server
lErr=lSession.Connect();
User::LeaveIfError(lErr);
TInetAddr lLSockAddr;
lLSockAddr.SetAddress(KInetAddrAny);
lLSockAddr.SetPort(4000);
//open the listening port
lErr = lListenSocket.Open(lSession,KAfInet, KSockStream,KProtocolInetTcp);
User::LeaveIfError(lErr);
console->Printf(_L("listening socket opened\n "😉);
lErr = lSocket.Open(lSession);
User::LeaveIfError(lErr);
console->Printf(_L("datasender socket opened\n "😉);
lErr = lListenSocket.Bind(lLSockAddr);
User::LeaveIfError(lErr);
console->Printf(_L("binding done\n "😉);
// Listen for incoming connections...
lListenSocket.Listen(1);
console->Printf(_L("listening with queue length 1\n "😉);
// and accept an incoming connection.
// On connection, subsequent data transfer will
// occur using the socket lSocket
AcceptNextConnectionL();
}
void CModel::RunL(void)
{
console->Printf(_L("Run called"😉);
if (status==KErrNone)
{
AcceptNextConnectionL();
// Connection has been established
// NotifyEvent(EEventConnected);
// Now need to start the receiver AO.
//iRxAO->RxL(iSocketType);
;
}
else // error condition
{
console->Printf(_L("Could not establish the connection"😉);
console->Getch();
}
}
GLDEF_C TInt E32Main()
{
// mark the head start
__UHEAP_MARK;
// create the obligatory cleanup stack
CTrapCleanup* cleanup=CTrapCleanup::New();
console=Console::NewL(_L("HelloText"😉,TSize(KConsFullScreen,KConsFullScreen));
console->Printf(_L("Hello world!\n"😉);
console->Printf(_L("[ press any key to continue]"😉);
console->Getch(); // get and ignore character
CModel* a=new (ELeave)CModel();
// CleanupStack::PushL(a);
TRAPD(error,a->StartEngineL());
CActiveScheduler::Start();
if(error)
{
console->Printf(_L("Exception caught!\n"😉);
console->Getch();
}
delete cleanup;
// mark the end
__UHEAP_MARKEND;
return 0;
}
But it does not work...
What is the error?