×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    105

    Where do I find iStatus error codes?

    Hello!

    Im trying to build a SocketClient for HTTP messaging. Some why I cant get any response for my POST requst even server get the request. I send this iStatus as a parameter that controls sockets connection. It has something to do with CActive object... In most case my Client works and iStatus returns -25 but after im trying to use our own Server application it return -2 and no response message. So im asking where do I find -2 and -25 error codes meaning?


    RSocket iSocket;

    class CGSHTTPClient : public CActive
    {
    ...
    iSocket.Write(iData, iStatus);
    ...
    }

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    224

    Thumbs up Re: Where do I find iStatus error codes?

    Hi,

    Error codes are defined in "e32std.h". FrameWork calls asynchronously when your request is complete with TRequestStatus (iStatus) RunL() on completion of the task.

    -2 KErrGeneral
    -25 KErrEof

    You can always find them in the above header file.
    Regards,
    shagor

  3. #3
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    105

    Re: Where do I find iStatus error codes?

    Thanks!

    Any idea why do I get -2 KErrGeneral error message? Any idea where could I get more information about this KErrGeneral message in socket use? This KErrGeneral doesnt help me a lot in this case.

    This is my POST request:
    _LIT8(KRequest, "POST HTTP/1.0\r\n\r\n Series 60 \n\r\n\r");


    void CGSHTTPClient::RunL()
    {
    switch (iState)
    {
    ...
    case EReceiving:
    {
    AppendToReceiveBuffer();
    if ( iStatus.Int() == KErrNone )//returns -2 and what does KErrGeneral means in this case?
    {
    DoReceiveL();
    }
    else
    {
    FinishConnectionL();
    }
    break;
    }

    default:
    break;
    }
    }

    void CGSHTTPClient:oReceiveL()
    {
    iRecvBuffer.SetLength(0);
    //Receives data from a remote host and completes when data is available.
    iSocket.RecvOneOrMore(iRecvBuffer, 0, iStatus, iLen);
    SetActive();
    }

  4. #4
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    224

    Re: Where do I find iStatus error codes?

    Hi,

    Just wonderring, what type of post request you made:
    _LIT8(KRequest, "POST HTTP/1.0\r\n\r\n Series 60 \n\r\n\r");

    You also have server side program for handling your http request. What type of application are you trying to make?

    Check this method: AppendToReceiveBuffer();

    You are making some mistake at the basic level. It's very hard to say looking that that portion of the code. Your error lies in very basic level. There are very good socket examples coming with SDK. I guess it would be very helpful if you go through the example. Best of luck.
    Regards,
    shagor

  5. #5
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    105

    Re: Where do I find iStatus error codes?

    Somehow we got this working in amulator but it aint work with cell phone.

    #include <aknquerydialog.h>
    #include <es_sock.h>
    #include <aknnotewrappers.h>
    #include <aknstaticnotedialog.h>

    #include "CGSHTTPClient.h"


    CGSHTTPClient* CGSHTTPClient::NewL(MSocketObserver *aCallb)
    {
    CGSHTTPClient* self = NewLC(aCallb);
    CleanupStack::Pop(self);
    return self;
    }

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

    CGSHTTPClient::CGSHTTPClient(MSocketObserver *aCallb) : CActive(CActive::EPriorityStandard),
    iState(ENotConnected),
    iCallb(aCallb)
    {
    CActiveScheduler::Add(this);
    }

    void CGSHTTPClient::ConstructL()
    {
    User::LeaveIfError( iSocketServer.Connect() );//Opens a session to the socket server.
    User::LeaveIfError( iSocket.Open(iSocketServer, KAfInet, KSockStream, KProtocolInetTcp) );
    }

    CGSHTTPClient::~CGSHTTPClient()
    {
    if (IsActive())
    {
    Cancel();
    }
    iSocket.Close();
    iSocketServer.Close();
    }

    // ----------------------------------------------------
    // void CGSHTTPClient:oCancel()
    // Active object DoCancel() interface implementation. Automatically called after cancel() called.
    // Means asynchronous request is canceled.
    // ----------------------------------------------------
    //
    void CGSHTTPClient:oCancel()
    {
    if (iState == ESending)
    {
    iSocket.CancelWrite();
    }
    if (iState == EReceiving)
    {
    iSocket.CancelRecv();
    }
    }

    // ----------------------------------------------------
    // void CGSHTTPClient::RunL()
    // active object RunL() interface implementation. Automatically called.
    // ----------------------------------------------------
    //
    void CGSHTTPClient::RunL()
    {
    switch (iState)
    {
    case ENotConnected:
    {
    break;
    }
    case EGettingConnection:
    {
    voidaan lähettää pyyntö
    iState = ESending;
    DoSendL();
    break;
    }
    case ESending:
    {
    iState = EReceiving;
    iData.SetLength(0); // Resets request
    DoReceiveL(); // Lets read response
    break;
    }
    case EReceiving:
    {
    AppendToReceiveBuffer();
    if ( iStatus.Int() == KErrNone ) //iStatus request state
    {
    DoReceiveL();
    }
    else
    {
    FinishConnectionL();
    }
    break;
    }
    default:
    break;
    }
    }

    // ----------------------------------------------------
    // void CGSHTTPClient::FinishConnectionL()
    // cancels all on going requests. Do callback and returns received data.
    // ----------------------------------------------------
    //
    void CGSHTTPClient::FinishConnectionL()
    {
    Cancel();

    iCallb->ResponseReceived( iData );
    }

    // ----------------------------------------------------
    // void CGSHTTPClient::SendL(TInetAddr &aIpAddress, const TDesC8& aDesc)
    // Takes connection to wanted address.
    // ----------------------------------------------------
    //
    void CGSHTTPClient::SendL(TInetAddr &aIpAddress, const TDesC8& aDesc)
    {
    iData = aDesc;
    iState = EGettingConnection;
    //Connects to a remote host. The address provided specifies the address of the remote host.
    //Once the connect is completed, the socket is ready to send or receive data.

    //The request iStatus associated with an asynchronous request.
    //This is passed as a parameter to all asynchronous service providers.
    //The active scheduler uses this to check whether the active object’s request has completed.

    iSocket.Connect( aIpAddress, iStatus );
    SetActive();
    }

    // ----------------------------------------------------
    // void CGSHTTPClient:oSendL()
    // Writes data in a socket which sends it to remote host.
    // ----------------------------------------------------
    //
    void CGSHTTPClient:oSendL()
    {
    //Write() should only be used with connected sockets.
    //On completion, iStatus will contain an error code
    iSocket.Write(iData, iStatus);

    //need to call immediately after asynchronous function call
    SetActive();
    }

    // ----------------------------------------------------
    // void CGSHTTPClient:oReceiveL()
    // saves response-blocks into iRecvBuffer.
    // ----------------------------------------------------
    //
    void CGSHTTPClient:oReceiveL()
    {
    iRecvBuffer.SetLength(0);
    //Receives data from a remote host and completes when data is available.
    iSocket.RecvOneOrMore(iRecvBuffer, 0, iStatus, iLen);
    SetActive();
    }

    // ----------------------------------------------------
    // void CGSHTTPClient::AppendToReceiveBuffer()
    // saves iRecvBuffer into IData which will be returned later in callback.
    // ----------------------------------------------------
    //
    void CGSHTTPClient::AppendToReceiveBuffer()
    {
    iData.Append( iRecvBuffer );
    iRecvBuffer.SetLength(0);
    }

  6. #6
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    105

    Re: Where do I find iStatus error codes?

    #include "CGSSync.h"

    _LIT(KLocalHost, "212.50.147.126");
    _LIT8(KRequest, "POST HTTP/1.1\r\n\r\n");
    const TInt KPort = 7656;

    CGSSync* CGSSync::NewL(MSocketObserver *aCallb)
    {
    CGSSync* self = NewLC(aCallb);
    CleanupStack::Pop(self);
    return self;
    }


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

    CGSSync::CGSSync(MSocketObserver *aCallb) : CActive(CActive::EPriorityStandard),
    iCallb(aCallb)
    {
    CActiveScheduler::Add(this);
    }

    void CGSSync::ConstructL()
    {
    TRAPD(error,OpenDatabaseL());
    if(error)
    {
    CreateDatabaseL();
    }
    CreateViewL();

    iGSHTTPClient = CGSHTTPClient::NewL( this );
    }


    CGSSync::~CGSSync()
    {
    if (IsActive())
    {
    Cancel();
    }
    delete iGSHTTPClient;

    iView.Close();

    iDatabase.Close();
    if (iStore)
    {
    delete iStore;
    }
    }

    // ----------------------------------------------------
    // void CGSSync::AuthAppToWebServL(TDesC &aUsername, TDesC &aPassword)
    // do application/user authentication in to WebService
    // ----------------------------------------------------
    //
    void CGSSync::AuthAppToWebServL(TDesC &aUsername, TDesC &aPassword)
    {
    TBufC<150> xmlBody;
    xmlBody = GenerateAuthenticationXMLBody(aUsername, aPassword);
    SendRequestL(xmlBody);
    }


    // ----------------------------------------------------
    // TDesC& CGSSync::GenerateAuthenticationXMLBody(TDesC &aUsername, TDesC &aPassword)
    // creates the GymSoft tables, inserts certain values into tables and returns authentication body
    // ----------------------------------------------------
    //
    TDesC& CGSSync::GenerateAuthenticationXMLBody(TDesC &aUsername, TDesC &aPassword)
    {
    /*
    <user>
    <authentication>
    <username>
    </username>
    <password>
    </password>
    </authentication>
    <user/>
    */
    TBufC<30> username = aUsername;
    TBufC<30> password = aPassword;

    TBuf<150> authenticationBody;

    _LIT(KUserS, "<user>");
    _LIT(KAuthenticationS, "<authentication>\n");
    _LIT(KUsernameS, "<username>\n");
    _LIT(KUsernameE, "</username>\n");
    _LIT(KPasswordS, "<password>\n");
    _LIT(KPasswordE, "</password>\n");
    _LIT(KAuthenticationE, "</authentication>\n");
    _LIT(KUserE, "<user/>");

    authenticationBody.Zero();

    authenticationBody.Append(KUserS);
    authenticationBody.Append(KAuthenticationS);
    authenticationBody.Append(KUsernameS);
    authenticationBody.Append(username);
    authenticationBody.Append(KUsernameE);
    authenticationBody.Append(KPasswordS);
    authenticationBody.Append(password);
    authenticationBody.Append(KPasswordE);
    authenticationBody.Append(KAuthenticationE);
    authenticationBody.Append(KUserE);

    return authenticationBody;
    }

    // ----------------------------------------------------
    // void CGSSync::SendRequestL(TDesC& aXmlBody)
    // attach Header and Body data. Calls HTTPClient object
    // with server address and request message to do request into server.
    // ----------------------------------------------------
    //
    void CGSSync::SendRequestL(TDesC& aXmlBody)
    {
    iServerAddr.Input( KLocalHost );
    iServerAddr.SetPort( KPort );

    TBuf8<400> param(KRequest);
    param.Append(aXmlBody);

    HBufC8* request = HBufC8::NewLC( param.Length());
    *request = param;

    iGSHTTPClient->SendL(iServerAddr, *request);
    CleanupStack::PopAndDestroy(); // request
    }

    // ----------------------------------------------------
    // void CGSSync::ResponseReceived(TDesC8 &aResponse)
    // this is called after HTTPClient has got response from server.
    // Function do callback and sends generated responseMSG about how communication succeed
    // ----------------------------------------------------
    //
    void CGSSync::ResponseReceived(TDesC8 &aResponse)
    {
    //TODO
    //palautuksen parserointi ja authentication iideen talletus tietokantaan

    _LIT(KParam, "authenticationID");
    TBufC<20> auth_id(KParam);

    iView.FirstL();

    iView.InsertL();

    iView.SetColL(1, auth_id);

    iView.PutL();

    iCallb->ResponseReceived( aResponse );
    }


    // ----------------------------------------------------
    // void CGSSync::CreateDatabaseL()
    // creates the GymSoft tables and insert certain values into tables
    // ----------------------------------------------------
    //
    void CGSSync::CreateDatabaseL()
    {
    TParse name;

    RFs fsSession = CCoeEnv::Static()->FsSession();//A handle to a file server session.
    fsSession.MkDirAll(KDbPath);//Makes one or more directories.
    fsSession.Parse(KDbName,KDbPath,name);//Parses a filename specification, specifying related file path components.
    iStore = CPermanentFileStore::ReplaceL(fsSession, name.FullName(), EFileRead|EFileWrite);
    iStore->SetTypeL(iStore->Layout());//Sets the UID type of the file store.

    TStreamId id;//Provides unique identification for stream within a store
    id = iDatabase.CreateL(iStore);
    iStore->SetRootL(id);
    iStore->CommitL();
    //create tables
    User::LeaveIfError(iDatabase.Execute(KDbUser));
    User::LeaveIfError(iDatabase.Execute(KDbInsert));
    }


    // ----------------------------------------------------
    // void CGSSync::OpenDatabaseL()
    // opens database for read
    // ----------------------------------------------------
    //
    void CGSSync::OpenDatabaseL()
    {
    TParse name;
    RFs fsSession = CCoeEnv::Static()->FsSession();
    fsSession.MkDirAll(KDbPath);
    fsSession.Parse(KDbName,KDbPath,name);
    iStore = CFileStore::OpenL(fsSession, name.FullName(), EFileRead|EFileWrite);//leaves with KErrNotSupported if there isn such database
    iDatabase.OpenL(iStore,iStore->Root());
    }

    // ----------------------------------------------------
    // void CGSSync::CreateViewL()
    // creates RDbView, that generates rowsets from an SQL query.
    // ----------------------------------------------------
    //
    void CGSSync::CreateViewL()
    {
    //SELECT auth_id FROM User
    User::LeaveIfError(iView.Prepare(iDatabase,TDbQuery(KDbView,EDbCompareNormal)));//Prepares the view object for evaluating an SQL select-statement.
    User::LeaveIfError(iView.EvaluateAll());//Evaluate the view
    }



    // ----------------------------------------------------
    // void CGSSync::UserAuthID(TDes& aDes)
    // add users authentication ID in a reference
    // ----------------------------------------------------
    //
    void CGSSync::UserAuthID(TDes& aDes)
    {
    //FirstL(), Positions the cursor on the first row in the rowset.
    //If there are no rows, the cursor is positioned at the end.

    TBufC<20> authID;
    if (iView.FirstL())
    {
    while(iView.AtRow())//Tests whether the cursor is on a row
    {
    iView.GetL();//Gets the current row data for access using the column extractor functions.

    authID = iView.ColDes(1);

    iView.NextL();//Moves the cursor to the next row in the rowset.
    }
    }

    aDes = authID;
    //aPaluu.Copy(paluu);
    }


    // ----------------------------------------------------
    // void CGSSync:oCancel()
    // Active object DoCancel() interface implementation. Automatically called after cancel() called.
    // Means asynchronous request is canceled.
    // ----------------------------------------------------
    //
    void CGSSync:oCancel()
    {

    }
    // ----------------------------------------------------
    // void CGSSync::RunL()
    // active object RunL() interface implementation. Automatically called.
    // ----------------------------------------------------
    //
    void CGSSync::RunL()
    {

    }

  7. #7
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    105

    Re: Where do I find iStatus error codes?

    Quote Originally Posted by khurshed79
    Hi,

    Just wonderring, what type of post request you made:
    _LIT8(KRequest, "POST HTTP/1.0\r\n\r\n Series 60 \n\r\n\r");
    Very a basic one that should work

    Quote Originally Posted by khurshed79
    You also have server side program for handling your http request. What type of application are you trying to make?
    Mobile phone should send data from database to server that would add data in servers database. After that database generates xml file by comparing posted data and servers database data and sends generated xml file back to Client.

    Quote Originally Posted by khurshed79
    Check this method: AppendToReceiveBuffer();

    You are making some mistake at the basic level. It's very hard to say looking that that portion of the code. Your error lies in very basic level. There are very good socket examples coming with SDK. I guess it would be very helpful if you go through the example. Best of luck.
    Somehow im feeling that I should finish this because its almost working
    Last edited by arachidyl; 2006-03-21 at 15:12.

  8. #8
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    105

    Re: Where do I find iStatus error codes?

    Got it working. Problem was our test 3G network...

    This aint work:
    POST HTTP/1.0\r\n\r\n Series 60 \n\r\n\r
    POST / HTTP/1.0\r\n\r\n Series 60 \n\r\n\r

    This works:
    POST MESSAGE HTTP/1.0\r\n\r\n Series 60 \n\r\n\r

Similar Threads

  1. Can not enter letter in find box! (Help me please!)
    By ctpthanh in forum Symbian User Interface
    Replies: 0
    Last Post: 2005-03-13, 08:41
  2. list box example
    By murmur20 in forum Symbian User Interface
    Replies: 1
    Last Post: 2004-11-09, 04:42
  3. how to handle find box event?
    By qianghstc in forum Symbian
    Replies: 2
    Last Post: 2004-08-06, 11:20
  4. Cannot find bluetooth devices
    By CTPELOK in forum Symbian
    Replies: 2
    Last Post: 2004-06-03, 08:39
  5. Find Box with KeyEvent Failure
    By Blkangel in forum Symbian
    Replies: 0
    Last Post: 2003-09-22, 09:00

Posting Permissions

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