×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    24

    Client program in .exe unable to send data

    I am writing client program in .exe (symbian series 60) and server program in VC++
    My problem
    1, after SetActive() it is not going to RunL()
    2,if give ClientRead() & ClientSend () in doExampleL() then only ClientRead() works but ClientSend () doesn’t work. Even I removed Client Read and called only Client Send then also client Send doesn’t works

    Same Client program I did it in .app it worked but now in .exe why RunL not invoked after SetActive

    #include"Client1EXE.h"
    #include "CommonFramework.h"

    LOCAL_C void doExampleL()
    {
    _LIT(KTxt11,"Testing the count server \n\n");
    console->Printf(KTxt11);
    CClientEngine * iClientEngine= CClientEngine::NewL();

    iClientEngine ->ConnectL();
    //iClientEngine->RunL();
    //iClientEngine ->ClientRead();// if I use this I am able to read form my server
    //iClientEngine ->ClientSend();// if I use this I am unable to Send to my server
    _LIT(KTxt101,"end\n\n");
    console->Printf(KTxt101);
    }

    //-------------------------- ClientEngine-------------------------------
    CClientEngine::CClientEngine() : CActive(EPriorityStandard)
    { }

    CClientEngine* CClientEngine::NewL()
    {
    CActiveScheduler* scheduler1 = new(ELeave)CActiveScheduler;
    //scheduler=scheduler1;
    CleanupStack::PushL(scheduler1);
    CActiveScheduler::Install(scheduler1);
    //CActiveScheduler::Start();
    CClientEngine* self = NewLC();
    CleanupStack::Pop();
    return self;
    }

    CClientEngine* CClientEngine::NewLC()
    {
    CClientEngine* self = new(ELeave) CClientEngine;
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
    }

    void CClientEngine::ConstructL()
    {
    CActiveScheduler::Add(this);
    _LIT(KTxt11,"ADD(this) \n\n");
    console->Printf(KTxt11);

    User::LeaveIfError(iSocketServ.Connect());
    User::LeaveIfError(iClientSocket.Open(iSocketServ, KAfInet, KSockStream, KProtocolInetTcp));
    iClientRead = CClientRead ::NewL(&iClientSocket);
    iClientSend = CClientSend::NewL(&iClientSocket);
    }

    void CClientEngine:: DoCancel()
    {
    iClientSocket.CancelConnect();
    }

    void CClientEngine::ConnectL()
    {
    iAddress.SetPort(9393);
    iAddress.SetAddress(INET_ADDR(192,168,1,129));
    iClientSocket.Connect(iAddress, iStatus);
    User::WaitForRequest(iStatus);
    SetActive();
    // CActiveScheduler::Start();
    // CActiveScheduler::Stop();
    }
    void CClientEngine::ClientSend ()
    {
    iClientSend-> IssueSend ();
    }
    void CClientEngine::ClientRead()
    {
    iClientRead->IssueRead1();
    }

    void CClientEngine::RunL()
    {
    if (iStatus == KErrNone)
    {
    _LIT(KTxt11,"Engine RunL \n\n");
    console->Printf(KTxt11);
    //CActiveScheduler::Stop();
    ClientRead();
    ClientSend ();
    }
    _LIT(KTxt11," RunL error\n");
    console->Printf(KTxt11);
    }

    CClientEngine::~CClientEngine()
    {
    _LIT(KTxt11," ~CClientEngine \n");
    console->Printf(KTxt11);
    delete iClientRead;
    delete iClientSend;
    iClientSocket.Close();
    iSocketServ.Close();
    }
    void CClientEngine::Stop()
    {
    _LIT(KETerminate,"\n<CClientEngine> Terminating\n");
    console->Printf(KETerminate);
    iClientRead->Cancel();
    iClientSend->Cancel();
    }

    //------------------------- Read --------------------------------
    // CClientRead: active object wrapping comms read requests
    //

    // Construction functions
    CClientRead::CClientRead() : CActive(EPriorityStandard)
    { }

    CClientRead* CClientRead::NewL(RSocket* aSocket)
    {
    CClientRead* self = NewLC(aSocket);
    CleanupStack::Pop();
    return self;
    }

    CClientRead* CClientRead::NewLC(RSocket* aSocket)
    {
    CClientRead* self = new(ELeave) CClientRead;
    CleanupStack::PushL(self);
    self->ConstructL(aSocket);
    return self;
    }

    void CClientRead::ConstructL(RSocket* aSocket)
    {
    // timer
    timer.CreateLocal();
    User::LeaveIfError(err);
    iClientSocket = aSocket;
    CActiveScheduler::Add(this);
    }

    void CClientRead:: DoCancel()
    {
    // iClientSocket->CancelRead();
    CleanupStack::PopAndDestroy(&fsSession);
    }

    CClientRead ::~CClientRead()
    {
    CleanupStack::PopAndDestroy(&fsSession);
    }

    void CClientRead::RunL()
    {
    if (iStatus == KErrNone)
    {}
    else
    {
    CleanupStack::PopAndDestroy(&fsSession);
    }
    }


    void CClientRead::IssueRead1()
    {
    (*iClientSocket).RecvOneOrMore(iClient_Read_Buffer8,0,iStatus iLength);

    User::WaitForRequest(iStatus);
    iClient_Read_Buffer16.Copy(iClient_Read_Buffer8);
    // HClient_Read_Buffer8=iClient_Read_Buffer.Alloc();

    timer.After(timerStatus,2000000);
    User::WaitForRequest(timerStatus);
    CleanupStack::PopAndDestroy(&fsSession);
    SetActive();
    }

    //----------------------- Send ------------------------------
    // CClientSend: active object wrapping comms Send requests
    //
    // Construction functions
    CClientSend::CClientSend () : CActive(EPriorityStandard)
    { }

    CClientSend* CClientSend::NewL(RSocket* aSocket)
    {
    CClientSend* self = NewLC(aSocket);
    CleanupStack::Pop();
    return self;
    }

    CClientSend* CClientSend::NewLC(RSocket* aSocket)
    {
    CClientSend* self = new(ELeave) CClientSend;
    CleanupStack::PushL(self);
    self->ConstructL(aSocket);
    return self;
    }

    void CClientSend::ConstructL(RSocket* aSocket)
    {
    iClientSocket = aSocket;
    CActiveScheduler::Add(this);
    }

    CClientSend::~CClientSend ()
    { }

    void CClientSend:: DoCancel()
    {
    iClientSocket->CancelSend ();
    }


    void CClientSend::RunL()

    {
    if (iStatus == KErrNone)
    {}
    else
    {}
    }


    void CClientSend::IssueSend ()
    {
    _LIT(KTxt11,"\nClient Send \n");
    console->Printf(KTxt11);

    _LIT(KHelloRom,"Appender by client HELLO");
    TBuf<46> KHelloref(KHelloRom);
    TBuf8<46> Khe;
    Khe.Copy(KHelloref);

    // User::WaitForRequest(iStatus);
    timer.After(timerStatus,15000000);
    (*iClientSocket).Send(Khe,0,iStatus);
    //User::WaitForRequest(iStatus);
    User::WaitForRequest(timerStatus);
    SetActive();
    }


    GLDEF_C TInt E32Dll(TDllReason)
    {
    return(KErrNone);
    }
    Last edited by k.sandeep; 2006-04-20 at 13:00.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,572

    Re: Client program in .exe unable to send data

    Your code pretends using some active objects, which it actually does not do. RunL methods will not be invoked as long as CActiveScheduler::Start is commented out. Note that CActiveScheduler::Start will not return until CActiveScheduler::Stop gets invoked (typically from one of your active objects).

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    8

    Re: Client program in .exe unable to send data

    Move the CActiveScheduler creation and starting out to doExampleL(), something like...
    LOCAL_C void doExampleL()
    {
    _LIT(KTxt11,"Testing the count server \n\n");
    console->Printf(KTxt11);
    CActiveScheduler* scheduler = new(ELeave) CActiveScheduler();
    CleanupStack::PushL(scheduler);
    CActiveScheduler::Install(scheduler);

    CClientEngine * iClientEngine= CClientEngine::NewLC();
    CActiveScheduler::Add(iClientEngine);
    iClientEngine ->ConnectL();
    CActiveScheduler::Start();

    CleanupStack::PopAndDestroy(iClientEngine);
    CleanupStack::PopAndDestroy(scheduler);

    _LIT(KTxt101,"end\n\n");
    console->Printf(KTxt101);
    }

    Then change CClientEngine::ConnectL() to use SetActive rather than WaitForRequest...
    void CClientEngine::ConnectL()
    {
    iAddress.SetPort(9393);
    iAddress.SetAddress(INET_ADDR(192,168,1,129));
    iClientSocket.Connect(iAddress, iStatus);
    SetActive();
    }

    And you should find that CClientEngine::RunL() is called when the socket is connected. You can then call read and write from there.

  4. #4
    Registered User
    Join Date
    Apr 2006
    Posts
    8

    Re: Client program in .exe unable to send data

    But now my problem is
    1. I want to call repeatedly call ClientRead();ClientSend (); in ClientEngine::RunL(),so what I did is

    void CClientEngine::RunL()
    {
    if (iStatus == KErrNone)
    {
    ClientWrite();
    // for(TInt a=0;a<5;a++)
    ClientRead();
    SetActive();
    }
    else{
    _LIT(KTxt11," RunL error\n");
    console->Printf(KTxt11);
    }
    }

    When it com to SetActive() exe is closing what is reason and when client read write RunL ( CClientRead::RunL , CClientWrite::RunL ) get activated
    I am didn’t understand nested active objects so can any one help me

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,572

    Re: Client program in .exe unable to send data

    It looks like that you have 3 active objects waiting for 2 events, but as you write, only 1 of them calls SetActive... Strange idea. Note that there is no such construct as "nested" Active Objects.
    Having CClientRead and CClientWrite AOs is a good idea, and they should wait for their particular event (I suppose, for completion of Socket::Read and Socket::Write, or something similar). But the "Engine" should not wait, it should rather provide some callbacks as "CClientEngine::ReadComplete", invoked from CClientRead::RunL upon completion.
    Also note that
    Code:
    ClientRead();
    ClientWrite();
    is not a really good approach in an asynchronous environment, since completion of read does not necessarily means completion - and the possibility of re-issuing - write.

Similar Threads

  1. unable to send data to imported dll functions
    By popeye_luck in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2005-09-13, 07:19
  2. unable to send data to imported functions in a dll
    By popeye_luck in forum Symbian
    Replies: 4
    Last Post: 2005-09-13, 07:18
  3. Http send and receive data
    By white_dragon in forum Symbian
    Replies: 1
    Last Post: 2005-02-02, 10:01
  4. Http send and receive data
    By white_dragon in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2004-11-17, 06:53
  5. Unable to Send SMS
    By abhishekmishra in forum Symbian
    Replies: 1
    Last Post: 2002-05-23, 14:11

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •