×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    22

    Thumbs up KErrAbort Error in UDP Socket

    Huy

    i receive first message correctly but after some time i receive a second message(i didnot send it from other side) with iStatus = KErrNone.

    Plz help me, Following is my code.

    //////////////////////////
    //////// UDPEngine.h /////
    //////////////////////////

    /* Copyright (c) 2001, Nokia Mobile Phones. All rights reserved */

    #ifndef __UDPENGINE_H__
    #define __UDPENGINE_H__

    #include <in_sock.h>
    #include "Sockets.hrh"

    class MUINotifier;

    class CUDPEngine : public CActive
    {
    public:

    static CUDPEngine* NewL(MUINotifier* aConsole);

    static CUDPEngine* NewLC(MUINotifier* aConsole);

    ~CUDPEngine();

    void BindL();

    void Disconnect();

    void WriteL(const TDesC8& aData,TInetAddr& aRemoteAddress);

    void Read();

    void SetPort(TInt aPort);

    TInt Port() const;

    void SetConsole(MUINotifier* aConsole);

    protected: // from CActive

    void DoCancel();

    void RunL();

    private: // New methods

    CUDPEngine(MUINotifier* aConsole);

    void ConstructL();

    private: // Member variables

    MUINotifier* iConsole;

    TRequestStatus iStatus;

    RSocket iSocket;

    RSocketServ iSocketServ;

    TInetAddr iAddress;

    TInetAddr iRemoteAddress;

    TInt iPort;

    TBuf8<50> iBuffer;
    };

    #endif // __UDPENGINE_H__



    /////////////////////////
    ///// UDPEngine.cpp /////
    /////////////////////////

    /* Copyright (c) 2001, Nokia Mobile Phones. All rights reserved */

    #include <eikgted.h>
    #include "UDPEngine.h"
    #include "Sockets.pan"
    #include "UINotifier.h"
    #include "MyCodes.h"
    #include "GlobalData.h"

    CUDPEngine* CUDPEngine::NewL(MUINotifier* aConsole)
    {
    CUDPEngine* self = CUDPEngine::NewLC(aConsole);
    CleanupStack::Pop(self);
    return self;
    }

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

    CUDPEngine::CUDPEngine(MUINotifier* aConsole): CActive(EPriorityStandard)
    {
    iConsole = aConsole;
    }

    CUDPEngine::~CUDPEngine()
    {
    Cancel();
    iSocketServ.Close();
    }


    void CUDPEngine::ConstructL()
    {
    CActiveScheduler::Add(this); // add active object
    User::LeaveIfError(iSocketServ.Connect()); // Open channel to Socket Server
    }

    void CUDPEngine::BindL()
    {
    User::LeaveIfError( iSocket.Open( iSocketServ, KAfInet, KSockDatagram, KProtocolInetUdp));
    iAddress.SetAddress(KInetAddrAny);
    iAddress.SetPort(iPort);
    User::LeaveIfError( iSocket.Bind(iAddress));
    Read();
    }

    void CUDPEngine:isconnect()
    {
    iSocket.Close();
    }

    // from CActive
    void CUDPEngine:oCancel()
    {
    iSocket.CancelRecv();
    iSocket.Close();
    }

    void CUDPEngine::WriteL(const TDesC8& aData,TInetAddr& aRemoteAddress)
    {
    iSocket.SendTo(aData,aRemoteAddress,0,iStatus);
    }

    void CUDPEngine::Read()
    {
    if(!IsActive())
    {
    iSocket.RecvFrom(iBuffer,iRemoteAddress,0,iStatus);
    SetActive();
    }
    }

    // from CActive
    void CUDPEngine::RunL()
    {
    TInt aError = iStatus.Int();
    TInt aAbort = KErrAbort;
    if (iStatus == KErrNone)
    {
    iConsole->OnUDPDataReceived(iBuffer);
    Read(); //Start Next Read
    }
    else
    {
    iSocket.Close();
    iConsole->OnErrorReceived(_L("Error Received."), iStatus.Int());
    }
    }

    void CUDPEngine::SetPort(TInt aPort)
    {
    iPort = aPort;
    }

    TInt CUDPEngine::Port() const
    {
    return iPort;
    }

    void CUDPEngine::SetConsole(MUINotifier* aConsole)
    {
    iConsole = aConsole;
    }

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,751

    Re: KErrAbort Error in UDP Socket

    "TRequestStatus iStatus;" is something you inherit from CActive. If you declare your own (as you do), the code will not work properly.

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    22

    Re: KErrAbort Error in UDP Socket

    huy

    thanks wizard_hu, your suggestion has solved my problem. thanks once again. i will ask some more question regarding my project plz keep answering me.

    regards

  4. #4
    Registered User
    Join Date
    Nov 2007
    Posts
    22

    Re: KErrAbort Error in UDP Socket

    huy

    i am facing a problem, problem is as follows,

    let suppose Form View A is activated & i bind a udp socket in it. Now when i receive a message from udp socket then i transit to another view (let FormView B) but when i wants to transit to previous view, application shows a global note "Requested object is used by another application". Please suggest where i am doing wrong. I am using carbide.c++ 1.2.

    Regards

Similar Threads

  1. ICMP: unreachable destination on UDP socket
    By rafikiel in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2007-09-04, 19:18
  2. problem in persistant socket connection
    By poms4symbian in forum Browsing and Mark-ups
    Replies: 0
    Last Post: 2006-01-03, 13:23
  3. j2me支持 udp socket 吗 ?
    By RongJia in forum [Archived] Other Programming Discussion 关于其他编程技术的讨论
    Replies: 5
    Last Post: 2005-09-16, 06:11
  4. Connected UDP Socket for NOKIA 9210
    By Kiran_Balu in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2003-10-14, 14:12
  5. TCP UDP socket
    By smallfish_ntu in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2003-08-19, 16:29

Posting Permissions

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