×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    42

    Emulator gets closed when data reaches on socket....

    Hi,
    my problem is that as soon as data reaches on the udp port where my udp socket reader object has issued RecvFrom(), emulator gets closed without hitting RunL().
    i have also checked using ethereal that data is reaching on the port where RecvFrom() is issued.


    *************************************************************
    //socket reader header.
    *************************************************************
    class CUdpSocketReaderublic CActive
    {
    private:
    CSocket *aOurSocket;
    //Will contain pointer to the socket which is containing this CUdpSocketReader object.

    LogManager *iLogManager;

    RSocket& iSocket;
    //Will be initialised with iSocket object contained in CSocket base class
    //which is containing this iSocket object.

    HBufC8 *ReadBuffer;
    //It will contain the received data.

    TInetAddr anAddr;
    //Will contain the address of remote host.

    public:
    static CUdpSocketReader* NewLC(CSocket *aSocket,RSocket& aSocketRef,TUint aReceivedDataBufferSize,LogManager* aLogManagerPtr);

    static CUdpSocketReader* NewL(CSocket *aSocket,RSocket& aSocketRef,TUint aReceivedDataBufferSize,LogManager* aLogManagerPtr);

    void ConstructL(TUint aReceivedDataBufferSize);

    CUdpSocketReader(CSocket *aSocket,RSocket& aSocketRef,LogManager* aLogManagerPtr);
    //Will allocate memory to the ReadBuffer pointer variable on Heap.
    //How much memory to allocate will be passed as argument in NewL() or NewLC().

    ~CUdpSocketReader();

    TInt ReadAsync(MHSSSocketMgrCallback* aEventListenerPtr=NULL);
    //Will issue Read() function of RSocket object Asynchronously.
    //Returns 1 for success n -1 for failure(if any).

    TInt RecvFromAsync(MHSSSocketMgrCallback* aEventListenerPtr=NULL);
    //Returns 1 for success n -1 for failure.
    //Will issue RcvFrom() function of RSocket object Asynchronously.

    void GetLengthOfDataRcvd(TUint& aLengthRef);
    //Synchronous implementation.
    //Length of Data will be returned in the aLengthRef through iLength variable.

    void GetReadBufData(TDesC8& aBufferRef);
    //Synchronous implementation.
    //Data will be returned in the aBufferRef argument.

    void GetUdpRcvdBuffer(TDes8& aBufferRef,TDes& aRemoteIpAddrRef,TUint& aRemotePortRef);
    //will return Data, Remote IP n Port in the arguments of above function.

    void RunL();
    //From CActive.

    void DoCancel();
    //From CActive.
    };
    //end of header file.
    *****************************************************************

    CUdpSocketReader* CUdpSocketReader::NewLC(CSocket *aSocket,RSocket& aSocketRef,TUint aReceivedDataBufferSize,LogManager* aLogManagerPtr)

    {
    CUdpSocketReader* self = new (ELeave) CUdpSocketReader(aSocket,aSocketRef,aLogManagerPtr);
    CleanupStack::PushL(self);
    self->ConstructL(aReceivedDataBufferSize);
    return self;
    }

    CUdpSocketReader* CUdpSocketReader::NewL(CSocket *aSocket,RSocket& aSocketRef,TUint aReceivedDataBufferSize,LogManager* aLogManagerPtr)
    {
    CUdpSocketReader* self = CUdpSocketReader::NewLC(aSocket,aSocketRef,aReceivedDataBufferSize,aLogManagerPtr);
    CleanupStack::Pop();
    return self;
    }

    void CUdpSocketReader::ConstructL(TUint aReceivedDataBufferSize)
    {
    ReadBuffer = HBufC8::NewL(aReceivedDataBufferSize);
    CActiveScheduler::Add( this );
    }

    CUdpSocketReader::CUdpSocketReader(CSocket *aSocket,RSocket& aSocketRef,LogManager* aLogManagerPtr)
    :CActive( EPriorityStandard ),
    aOurSocket(aSocket),
    iSocket(aSocketRef),
    iLogManager(aLogManagerPtr)
    {
    }

    void CUdpSocketReader::RunL()
    {
    iLogManager->LmPrint(Debug,_L("%s"),_S(RunL hitted));
    if(iStatus == KErrNone)
    aOurSocket->CallbackToSocket(EHSSDataReceived,iStatus.Int());
    else
    aOurSocket->CallbackToSocket(EHSSDataReceivingFailed,iStatus.Int());
    }


    TInt CUdpSocketReader::RecvFromAsync(MHSSSocketMgrCallback* aEventListenerPtr)
    {
    if(IsActive())
    return -1;
    iSocket.RecvFrom(ReadBuffer->Des(),anAddr,0,iStatus);
    //iStatus variable is from CActive class.

    SetActive();//From CActive.
    return 1;
    }

    After this point control returns back to the statement in my exe which is:
    CActiveScheduler::Start();

    n after it program is in waiting state, i am assuming that it is in AS's start loop n waiting for RunL() of RecvFrom() to be hitted.
    But as soon as data arrives on this port where socket has issued RecvFrom(), emulator gets closed, RunL() does not get hit.
    Last edited by Amit Mahajan; 2006-05-01 at 05:42.

  2. #2
    Registered User
    Join Date
    Apr 2006
    Posts
    2

    Re: Emulator gets closed when data reaches on socket....

    Don't use a socket manager whose design is based in line with the one used earlier

Similar Threads

  1. suckho, i have encontered the same problems. Could you tell me how you resolved it?
    By dicson_hu in forum Symbian Networking & Messaging (Closed)
    Replies: 4
    Last Post: 2005-12-09, 10:56
  2. GPRS connection problems on 6600..
    By suckho in forum Symbian Networking & Messaging (Closed)
    Replies: 10
    Last Post: 2005-12-02, 14:00
  3. Nokia 6600 Socket Server send delay Problem
    By dicson_hu in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2005-10-31, 07:37
  4. Socket received data converted to unicode doesn't display the full informat
    By prsens in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2003-03-17, 03:36

Posting Permissions

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