×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    20

    Application is crashed when connecting to a socket

    I use this code in handle key event function but everytimes click on button, simualator is crashed. Im newbie with Symbian C++. Thank for your helping.

    PHP Code:
            RSocketServ ss;
            
    TRequestStatus status;
            
    RConnection conn;

            
    _LIT(KRasAddr,"127.0.0.1");
            const 
    TInt KEchoPort 7;

            
    TInetAddr destAddr;
            
    destAddr.Input(KRasAddr);
            
    destAddr.SetPort(KEchoPort);

            
    // Connect to the socket server
            
    ss.Connect();

            
    // Open an RConnection object. Note that you must provide the RSocketServ object
            
    conn.Open(ss);

            
    // Create overrides
            
    TCommDbConnPref prefs;
            
    prefsSetDialogPreference(ECommDbDialogPrefDoNotPrompt);
            
    prefs.SetDirection(ECommDbConnectionDirectionOutgoing);
            
    prefs.SetIapId(4);

            
    // Start an Outgoing Connection with overrides
            
    conn.Start(prefs);

            
    // Open a Host Resolver associated with the connection
            
    RHostResolver hr;
            
    hr.Open(ssKAfInetKProtocolInetTcpconn);

            
    // Open a Socket associated with the connection
            
    RSocket sock;
            
    sock.Open(ssKAfInetKSockStreamKProtocolInetTcpconn);

            
    // Request the Socket to connect to the destination
            
    sock.Connect(destAddrstatus);
                    
                    
    // Neu khong loi
                    
    if(status == KErrNone){
                            
                            
    _LIT(Mes,"message");
                            
    CConsoleBase *gConsole Console::NewL(MesTSize(KConsFullScreen,KConsFullScreen 10));
                            
    _LIT(KHelloWorldString"Ket noi thanh cong\n");
                            
    gConsole->Printf(KHelloWorldString);
                    }
                    
                    
    //Neu loi
                    
                    
    else{
                    
    _LIT(Mes,"message");
                    
    CConsoleBase *gConsole Console::NewL(MesTSize(KConsFullScreen,KConsFullScreen 10));
                    
    _LIT(KHelloWorldString"Ket noi khong thang cong\n");
                    
    gConsole->Printf(KHelloWorldString);
                    } 

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,567

    Re: Application is crashed when connecting to a socket


  3. #3
    Registered User
    Join Date
    Jun 2009
    Posts
    20

    Re: Application is crashed when connecting to a socket

    I modify my Emulator like this

    http://ca5.upanh.com/13.230.17458577.HFo0/untitled.png

    modify epoc.ini

    PHP Code:
    configuration epoc_240x320.ini
    configuration epoc_240x320_keypadoff
    .ini
    configuration epoc_320x240
    .ini
    configuration epoc_320x240_keypadoff
    .ini
    configuration epoc_240x320_f
    .ini
    configuration epoc_240x320_keypadoff_f
    .ini
    configuration epoc_320x240_f
    .ini
    configuration epoc_320x240_keypadoff_f
    .ini
    PlatSecDiagnostics ON
    PlatSecEnforceSysBin ON
    PlatSecProcessIsolation ON
    PlatSecEnforcement OFF
    PlatSecDisabledCaps NONE
    LogToFile 1
    LogToDebugger 1
    JustInTime 0
    _EPOC_DRIVE_D 
    \epoc32\winscw\d
    _EPOC_DRIVE_E
    _EPOC_LocDrv_1
    MegabytesOfFreeMemory 32
    MultiMediaCardSize
    =16000
    patchdata_apserv_dll_KApaLoadDataRecognizersOnDemand 1
    etel_KPriorityClientSid 0x100058B3
    WindowTitle S60 3rd Edition FP2 SDK v1.1 

    and my code
    PHP Code:
            RSocketServ ss;
            
    RSocket sock;
            
    TRequestStatus status;

            
    _LIT(KRasAddr,"127.0.0.1");
            const 
    TInt KEchoPort 7;

            
    TInetAddr destAddr;
            
    destAddr.Input(KRasAddr);
            
    destAddr.SetPort(KEchoPort);
            
    ss.Connect();
            
    sock.Open(ssKAfInetKSockStreamKProtocolInetTcp);
            
    sock.Connect(destAddrstatus); 
    But still crashed. I open file errrd and only see
    PHP Code:
    ECHO is off
    What i have to do to know why emulator is crashed.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,567

    Re: Application is crashed when connecting to a socket

    The ErrRd file is just a flag, it causes the error message to get displayed on the screen of the emulator.
    Anyway, if your emulator gets closed, the error message should be the last line in its logfile: http://wiki.forum.nokia.com/index.php/Epocwind.out

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,567

    Re: Application is crashed when connecting to a socket

    Ok, now I see. Your emulator may not crash at all, just your application exits.
    Whenever you see a TRequestStatus passed as argument, an asynchronous request starts. So Connect returns in a moment, but the socket is actually not connected, it is just under processing.
    The simplest way to wait until that something happens is issuing a User::WaitForRequest(status).
    And it would be a good idea to wait for a keypress at the end, gConsole->Getch() would do that. Otherwise your application writes the message to the display, then exits in 1-2 microseconds.
    A side note: KConsFullScreen is a "magic number", it is -1, so dividing it with 10 may not provide the expected result.

  6. #6
    Registered User
    Join Date
    Jun 2009
    Posts
    20

    Re: Application is crashed when connecting to a socket

    Thank you very much. I have learned Symbian C++ for 2 weeks and forgot about Active Object I also didnt add User::WaitForRequest(status);
    Source code for who has same problem and googling
    Code:
    		RSocketServ ss;
    		RSocket sock;
    		TRequestStatus status;
    		
    		_LIT(KRasAddr,"127.0.0.1");
    		const TInt KEchoPort = 1458;
    		
    		TInetAddr destAddr;
    		destAddr.Input(KRasAddr);
    		destAddr.SetPort(KEchoPort);
    		ss.Connect();
    		sock.Open(ss, KAfInet, KSockStream, KProtocolInetTcp);
    		sock.Connect(destAddr, status);
    		User::WaitForRequest(status);
    		
            _LIT(Mes,"message"); 
            CConsoleBase *gConsole = Console::NewL(Mes, TSize(KConsFullScreen,KConsFullScreen)); 
    	       if(status == KErrNone){ 
    	                        _LIT(KHelloWorldString, "Connection failed\n"); 
    	                        gConsole->Printf(KHelloWorldString); 
    	                } 
    	                 
    	                else{ 
    	                _LIT(KHelloWorldString, "Connected\n"); 
    	                gConsole->Printf(KHelloWorldString); 
    	                }  
    	       gConsole->Getch();
    Last edited by JulianoLoren; 2010-09-14 at 08:43.

Similar Threads

  1. Application crashed on E61 & E71
    By kalpesh.dev in forum Symbian User Interface
    Replies: 14
    Last Post: 2009-10-30, 13:34
  2. Replies: 1
    Last Post: 2009-07-14, 09:16
  3. Application crashed when another application acquires camera
    By binli120 in forum Symbian Media (Closed)
    Replies: 3
    Last Post: 2006-10-16, 20:17
  4. crashed application
    By Vitaly_iva in forum Symbian User Interface
    Replies: 6
    Last Post: 2006-04-21, 20:03
  5. Removing Crashed Application (S60)
    By bhollister in forum Mobile Java General
    Replies: 1
    Last Post: 2003-12-29, 07:09

Posting Permissions

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