×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    88

    Post [moved] TCP Listener With Active object problem

    Following code run fine without active object but when i put
    into active object(A.O) application close with returning iStatus -18..Please check code & Reply Thank you!!!!

    TInt KTestPort = 80;
    TInetAddr addr(KInetAddrAny, KTestPort);
    RSocketServ socketServ;
    RSocket blank;
    RSocket listener;


    //Connect State(In RunL Different state this Method Called 1st )
    void Connect ()
    {
    socketServ.Connect();
    listener.Open(socketServ, KAfInet, KSockStream, KProtocolInetTcp);
    listener.Bind(addr);
    listener.Listen(1);
    //here state change to ListenAccept
    SetActive();
    }

    ListenAccept state( this method call from RunL)
    void ListenAccept ()
    {
    blank.Open(socketServ);
    listener.Accept(blank, iStatus );
    *******CODE BLOCK HERE.......******return iStatus -18.

    //To avoid blocking code instead of User::WaitForRequest(iStatus);
    //added some delay using RTimer::After(2 sec.)

    /here state change to ReadData
    SetActive();

    }

    void ReadData Method( This method called continuosly after every 2sec.)
    {
    if(iStatus != KErrNone)
    User::Leave(KErrGeneral);

    TBool running = ETrue;
    //TBool boolean;
    TBuf8<256> buffer;
    TSockXfrLength len;

    blank.RecvOneOrMore(buffer, 0, iStatus, len);

    // User::WaitForRequest(iStatus);
    //added some delay using RTimer::After(2 sec.)

    if(iStatus != KErrNone)
    User::Leave(KErrGeneral);

    logMe(buffer);//For just Display Recvdata
    iblank.Close();
    ilistener.Close();
    iConnection.Close();
    //here state change again to open connection then
    SetActive();
    }

  2. #2
    Super Contributor
    Join Date
    Jul 2008
    Location
    Chennai,India
    Posts
    889

    Re: TCP Listener With Active object problem

    Error -18 is KErrNotReady...

    I am sure that your socket is not created succesfully..
    Better check the return status of OPen, Bind,...

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: TCP Listener With Active object problem

    Invoking SetActive without passing iStatus to some method (as you do in "Connect") is a bad idea. Do not do that.

  4. #4
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    88

    Re: TCP Listener With Active object problem

    Thanks for reply ...BUT RSocketServ Connect() method doesn't take 'iStatus' as argument.So where should i pass 'iStatus' . And while Connect() & open() my iStatus is 0(KErrNone). So Where is problem..

  5. #5
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    88

    Re: TCP Listener With Active object problem

    i checked return status of OPen, Bind,...iStatus=0 i.e(KErrnone),So what should be the problem....? Thanks!!!

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: TCP Listener With Active object problem

    Quote Originally Posted by uday.neo View Post
    Thanks for reply ...BUT RSocketServ Connect() method doesn't take 'iStatus' as argument.So where should i pass 'iStatus'.
    Nowhere, RSocketServ::Connect is a synchronous method, it does not initiate a network connection, but it connects your application with the Socket Server. This kind of "connection" happens internally in the device, so it can (and do) provide the result immediately, there is no need for TRequestStatus.

  7. #7
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    88

    Re: TCP Listener With Active object problem

    ur last Re: TCP Listener With Active object problem - Yesterday, 14:31
    Invoking SetActive without passing iStatus to some method (as you do in "Connect") is a bad idea. Do not do that.

    and now current reply
    Nowhere, RSocketServ::Connect is a synchronous method, it does not initiate a network connection, but it connects your application with the Socket Server. This kind of "connection" happens internally in the device, so it can (and do) provide the result immediately, there is no need for TRequestStatus.

    So What is soln i didn't get it?Where is problem?

  8. #8
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: TCP Listener With Active object problem

    You should not invoke SetActive before listener.Accept. That is the first method on server side, which accepts TRequestStatus.

  9. #9
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    88

    Re: TCP Listener With Active object problem

    I am getting USER 23 panic in this application. As i Know this is due to Descriptor Overflow. But NoWhere, till Accept(Where apps block) I am using Descriptor here so where i went wrong here?

  10. #10
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: TCP Listener With Active object problem

    You can and should check that in the emulator+debugger. If you enable Just In Time debugging in the preferences of the emulator, the debugger (given that you execute the code in debug mode) will show where the panic occurs.

  11. #11
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    88

    Red face Re: [moved] TCP Listener With Active object problem

    1]I am able to read & write Data on socket 1 time only but i want it continous?
    2]Only on any UI click able to connect?
    void CServerEngine::RunL()
    {
    if (iStatus == KErrNone)
    {
    switch(iServerMode)
    {
    case EServerNone:
    {
    ConnectionL();
    }break;

    case EServerReadMode:
    {
    ReadServerData();
    }break;
    case EWaitStatusMode:
    {
    WaitForStatus();
    }break;
    }
    }
    else
    {
    iblank.Close();
    ilistener.Close();
    iServerMode=EServerNone;
    ConnectionL();
    }

    }

    void CServerEngine::ConnectionL()
    {
    TInetAddr iaddr(KInetAddrAny, KTestPort);
    ilistener.Open(iSocketServ, KAfInet, KSockStream, KProtocolInetTcp));


    ilistener.Bind(iaddr);

    ilistener.Listen(1);

    RTimer timer;
    timer.CreateLocal();

    TRAPD(err5,iblank.Open(iSocketServ)); //Second Time Code stop Here & close application
    if(err5 == KErrNone)
    {

    ilistener.Accept(iblank, iStatus);
    timer.After(iStatus,(10*KSecond));

    }


    iServerMode=EWaitStatusMode;
    SetActive();

    }

    }

    void CServerEngine::WaitForStatus()
    {
    if(iStatus !=KErrNone)
    {
    iblank.Close();
    ilistener.Close();
    iServerMode=EServerNone;
    SetActive();
    }

    else
    {

    iServerMode=EServerReadMode;
    SetActive();
    }

    }

    void CServerEngine::ReadServerData()
    {

    ListenData(buffer);
    }

    void CServerEngine::ListenData(TDes8& buffer)
    {
    RTimer timer;
    timer.CreateLocal();
    iblank.RecvOneOrMore(buffer, 0, iStatus, len);
    iblank.Write(buffer, iStatus);
    iblank.Close();
    ilistener.Close();
    iServerMode=EServerNone;
    SetActive();

    }

    void CServerEngine::CloseConnectionL()
    {
    iblank.Close();
    ilistener.Close();
    iSocketServ.Close();
    iConnection.Close();
    }

    What should be the problem Please reply?
    Last edited by uday.neo; 2008-11-11 at 12:48.

Similar Threads

  1. Replies: 2
    Last Post: 2007-10-05, 20:40
  2. Replies: 6
    Last Post: 2007-08-03, 04:04
  3. Replies: 6
    Last Post: 2007-06-14, 22:02
  4. ACTIVE OBJECT RUNL Problem
    By pavan in forum Symbian
    Replies: 4
    Last Post: 2006-11-07, 16:09
  5. Replies: 1
    Last Post: 2002-08-28, 09:12

Posting Permissions

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