×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    13

    SecureSocket issues in a thread.

    Hi All,

    Will the CSecureSockets work in a user created thread? I launch a thread and in that I create a CSecureSocket, but the application crashes when I try to instantiate it:

    CSecureSocket *secureSock = CSecureSocket::NewL(*m_sock, _L("SSL3.0"));

    But the same code works in a UI thread. Is there something I should initialize after launching the thread?

    Foll. is the code:

    void ThreadProc()
    {
    my_log("ThreadProc: Start: Entry.\n");

    RSocketServ socketServ;
    RConnection connection;

    TRequestStatus status;

    socketServ.Connect();

    connection.Open(socketServ);

    connection.Start(status);
    User::WaitForRequest(status);

    my_log("After Connection Start\n");

    // Create the socket first.
    RSocket *m_sock = new RSocket();

    TInetAddr remoteAddr;
    remoteAddr.SetAddress(INET_ADDR(63, 245, 209, 11));//63.245.209.11
    remoteAddr.SetPort(443);
    remoteAddr.SetFamily(KAfInet);

    TInt iErr = m_sock->Open(socketServ, KAfInet, KSockStream, KProtocolInetTcp, connection);

    my_log("After Socket Open\n");

    m_sock->Connect(remoteAddr, status);
    User::WaitForRequest(status);

    if (status == KErrNone)
    {
    my_log("After Socket Connect\n");
    CSecureSocket *secureSock = CSecureSocket::NewL(*m_sock, _L("SSL3.0")); // Crashes here
    my_log("After Secure Socket Creation\n");
    }
    else
    {
    my_log("Socket Connect failed, err: %d\n", status.Int());
    return;
    }

    my_log("ThreadProc: Start: Entry.\n");
    }


    LOCAL_C void MainL()
    {
    RThread *mThread = new RThread();

    mThread->Create( _L(""), //thread name
    (TThreadFunction)ThreadProc,//pointer to a function
    65536,
    NULL,
    NULL);

    my_log("Resuming the thread.\n");

    mThread->Resume();

    User::After(600000000);
    }


    Thanks.

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

    Re: SecureSocket issues in a thread.

    In short: do not use threads, because you do not need them.

    Extended version: enable the panic codes (http://wiki.forum.nokia.com/index.ph...ded_panic_code) and you will see what is missing: the Cleanup Stack. Most R-classes do not use it, but a CSomething::NewL obviously does.

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    13

    Re: SecureSocket issues in a thread.

    Thank you wizard_hu_, the problem was I was not using CTrapCleanup in my thread.

Similar Threads

  1. emulator startup failed
    By hony in forum Symbian User Interface
    Replies: 3
    Last Post: 2008-11-11, 06:07
  2. Carbide C++ : ..... .pkg does not exist. Skipping...
    By satishkatta in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 144
    Last Post: 2008-08-07, 11:16
  3. Socket and thread issues with UI programming
    By mcloke74 in forum Symbian
    Replies: 3
    Last Post: 2005-06-30, 09:13
  4. Thread issues....
    By conor026 in forum Mobile Java General
    Replies: 1
    Last Post: 2005-02-15, 08:22

Posting Permissions

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