×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Jul 2005
    Posts
    168

    problem on connection to my server

    hi,
    i have written a server.exe program. And when i try to connect it from my client program with the function CreateSession(...),
    this function returns -1. Here is some of my codes:

    codes for server.exe :--------------------------------
    void TServerStart::SignalL()
    {
    CTrapCleanup* cleanup=CTrapCleanup::New();
    TRAPD(error,MainL());

    RThread client;
    User::LeaveIfError(client.Open(iId));
    client.RequestComplete(iStatus, KErrNone);
    client.Close();

    TRAPD(errorx,MainL());
    delete cleanup;
    }// end of SignalL()

    void CServSession::CreateL(const CServer& aServer)
    {
    CSharableSession::CreateL(aServer); // cannot leave
    Server().AddSession();
    //iAsyncRequestHandler = CAsyncHandler::NewL();
    }//end of CreateL()

    void CServSession::ServiceL(const RMessage& aMessage)
    {
    switch (aMessage.Function())
    {
    case (EStartWatching):
    {
    //
    RFs fs;
    User::LeaveIfError(fs.Connect());
    CleanupClosePushL(fs);
    RFile file;

    User::LeaveIfError(file.Create(fs, KFILE, EFileWrite));

    CleanupClosePushL(file);
    file.Close();
    CleanupStack::PopAndDestroy();
    fs.Close();
    CleanupStack::PopAndDestroy();
    }
    //
    break;
    case (EStopWatching):
    StopWatching(aMessage); //serveri kapatma sakin
    break;

    default:
    PanicClient(aMessage,EPanicNotSupported);
    break;
    }
    }// end of ServiceL()

    CServer* CServerClass::NewLC()
    {
    CServerClass* self=new(ELeave) CServerClass;

    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
    }

    // Starts the server and constructs the shutdown object, starting the timer to ensure that
    // the server will exit even if the starting client connection fails
    void CServerClass::ConstructL()
    {
    StartL(KServerName);
    }// end of ConstructL()

    void RunTheServerL(TServerStart& aStart)
    {// First create and install the active scheduler
    CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
    CleanupStack::PushL(scheduler);
    CActiveScheduler::Install(scheduler);

    // create the server
    CServerClass::NewLC(); // Sorun yok

    // Naming the server thread after the server helps to debug panics
    User::LeaveIfError(RThread().Rename(KServerName));

    // Signal the client that initialization is complete
    aStart.SignalL();

    // Enter the wait loop
    CActiveScheduler::Start();

    // Exited - cleanup the server and scheduler
    CleanupStack::PopAndDestroy(2, scheduler);
    }// end of RunTheServerL()


    TInt RunTheServer(TServerStart& aStart)
    {
    __UHEAP_MARK; // Heap checking

    CTrapCleanup* cleanup=CTrapCleanup::New();
    TInt r=KErrNoMemory;
    if (cleanup)
    {
    TRAP(r,RunTheServerL(aStart));
    delete cleanup;
    }
    __UHEAP_MARKEND;
    return r;
    }

    TInt TServerStart::GetCommand()
    {

    RProcess serverProcess;
    TPtr ptr(reinterpret_cast<TText*>(this),0,sizeof(TServerStart)/sizeof(TText));
    serverProcess.CommandLine(ptr);
    return KErrNone;
    }

    TInt E32Main()
    {
    TServerStart start;
    TInt r=start.GetCommand();

    if (r==KErrNone)
    r=RunTheServer(start);

    return r;
    }

    //----------------------------
    i make my server.exe autostart when the phone starts and in my client program :

    TInt RSessionClass::Connect()
    {
    TInt retry=2;
    for (;
    {// Uses system-pool message slots
    TInt r=CreateSession(KServerName,TVersion(1,0,0));
    //TInt r=CreateSession(KServerName,Version(),kDefaultMessageSlots);
    if ( (KErrNotFound!=r) && (KErrServerTerminated!=r) )
    return (r);
    if (--retry==0)
    return (r);
    }
    }//end of Connect

    when i call the lines :
    RSessionClass session;
    TInt r = session.Connect();

    r returns as -1.

    Please help, i tried lots of combinations, but could not run correctly...

  2. #2
    Super Contributor
    Join Date
    Jun 2006
    Location
    India
    Posts
    3,037

    Re: problem on connection to my server

    hi!
    can u tell me what is CreateSession and its a predefine API and u r using it without creating the object of the class from which this belongs.
    TInt r=CreateSession(KServerName,TVersion(1,0,0));

    if u r using RSessionBase class for creating the session then u have to write like :

    RSessionBase session.
    session.connect(parameters...)

    i hope this will help u ?

    Regards
    KKrish

  3. #3
    Regular Contributor
    Join Date
    Jul 2005
    Posts
    168

    Re: problem on connection to my server

    i am calling CreateSession from a RSessonBase derived class, RSessionClass that you can see in the code that i sent.
    you will see that i am writing my own Connect() method in that code. And in my implementation of Connect, i am calling RSessionBase::CreateSession() method.... Then what is wrong here

Similar Threads

  1. Problem in reconnection from client to server
    By Palermo4Ever in forum Bluetooth Technology
    Replies: 0
    Last Post: 2006-06-19, 16:27
  2. connecting problem with a server
    By mbicer00 in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2006-06-11, 17:54
  3. Problem: RGenericAgent::Progress does not detect open connection
    By bjorn.rudolfsson in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2004-02-18, 08:59
  4. problem with secure connection
    By wadim in forum OMA DM/DS/CP
    Replies: 2
    Last Post: 2003-12-24, 00:53
  5. Problem with server example...
    By rusyaev in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2003-03-21, 13:44

Posting Permissions

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