×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    10

    Question make connection local on console??

    i want make connection locally on device(7610),,

    here's my problem,,i want to connect 2 application via socket,,that i know it should be connect via localhost on device
    and it doesn't work

    i want to listen sms
    when sms go to inbox or sent item i want send it via localhost and the other app will get it and save it

    i used console and smsHandler

    the problem is my socket connection,,i think
    because my other app won't receive it

    anyone know??

  2. #2
    Registered User
    Join Date
    Jun 2009
    Posts
    10

    Re: make connection local on console??

    here my console code


    #include <es_sock.h>
    #include <in_sock.h>
    #include "SMSServer.h"
    #include <e32base.h>
    #include <e32std.h>
    #include <e32cons.h> // Console
    #include "SMSEngine.h" //sms messaging engine
    #include <msvuids.h>
    #include <msvids.h>


    _LIT(KTextConsoleTitle, "Console");
    _LIT(KTextFailed, " failed, leave code = %d");
    _LIT(KTextPressAnyKey, " [press any key]\n");
    const TMsvId KInbox = KMsvGlobalInBoxIndexEntryId;



    LOCAL_D CConsoleBase* console; // write all messages to this

    RSocketServ* iSocketServer;
    RSocket* iSocket;
    RSocket* iServiceSocket;

    TInetAddr iAddress;

    HBufC8* iBuffer;
    TRequestStatus iStatus;
    TDes8* aBuffer;


    LOCAL_C void MainL()

    TRAPD(e1, ConnectSymbianOSServer());
    if (e1){console->Write(_L("Connecting SymbianOS Server error\n"));}else{
    console->Write(_L("Connecting SymbianOS Server\n"));}
    TRAPD(e2, OpenSocket());
    if (e2){console->Write(_L("Openning Socket error\n"));}else{
    console->Write(_L("Openning Socket\n"));
    }
    TRAPD(e3, ConnectSocket());
    if (e3){console->Write(_L("Connecting Socket errror\n"));}else{
    console->Write(_L("Connecting Socket\n"));}
    iEngine = CSmsEngine::NewL();
    iEngine->setCon(console);
    iEngine->setSock(iSocket);
    iEngine->CreateLocalMessageL( KInbox,
    _L("+50000"),
    _L("From me"),
    _L("From me to you")
    );

    }

    LOCAL_C void ConnectSymbianOSServer()
    {
    // Connect to the Symbian OS Socket Server.
    TInt err = iSocketServer->Connect();
    if (err != KErrNone && err != KErrAlreadyExists)
    {
    User::Leave(err);
    }
    }

    LOCAL_C void OpenSocket()
    {
    TInt err;

    // Open socket
    err = iSocket->Open(*iSocketServer, KAfInet, KSockDatagram,KProtocolInetUdp);

    if (err != KErrNone && err != KErrAlreadyExists)
    {
    User::Leave(err);
    }
    }

    LOCAL_C void ConnectSocket()
    {
    TUint KTestPort=8100;
    TInetAddr addr(KInetAddrLoop, KTestPort);
    iSocket->Bind(addr);
    }

    LOCAL_C void Write( TUint chargeLevel )
    {
    if( iBuffer )
    {
    delete iBuffer;
    iBuffer = NULL;
    }


    aBuffer->Num(chargeLevel);

    TRAPD( err, iBuffer = aBuffer->AllocL() );
    iSocket->Write(*aBuffer, iStatus);
    }

    LOCAL_C void DoStartL()
    {
    CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
    CleanupStack::PushL(scheduler);
    CActiveScheduler::Install(scheduler);

    MainL();
    CActiveScheduler::Start();
    CleanupStack::PopAndDestroy(scheduler);
    }

    GLDEF_C TInt E32Main()
    {
    __UHEAP_MARK;
    CTrapCleanup* cleanup = CTrapCleanup::New();
    iSocketServer = new (ELeave) RSocketServ;
    iSocket = new (ELeave) RSocket;
    TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(
    KConsFullScreen, KConsFullScreen)));
    if (createError)
    return createError;
    TRAPD(mainError, DoStartL());
    if (mainError)
    console->Printf(KTextFailed, mainError);
    console->Printf(KTextPressAnyKey);
    console->Getch();

    delete console;
    delete cleanup;
    __UHEAP_MARKEND;
    return KErrNone;
    }


  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: make connection local on console??

    You should check existing socket-related examples, as I remember there is Series60Ex\Socket in the S60 2nd edition SDK-s.
    A first-glance problem is that if you use UDP, you should use SendTo and RecvFrom. And you use mis-leading naming conventions, and your code is neither an active object, nor a blocking one. Though it may still work for a single shot.

Similar Threads

  1. Build Error on Carbide
    By deepak_pious in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 3
    Last Post: 2010-05-23, 09:37
  2. my first app prj build block
    By linbo-lmx in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 4
    Last Post: 2007-12-07, 21:19
  3. errors when building?
    By neilxp in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2007-04-18, 14:10
  4. abld make files missing
    By dalore in forum Symbian
    Replies: 0
    Last Post: 2003-06-13, 12:40
  5. Replies: 5
    Last Post: 2003-02-07, 11:25

Posting Permissions

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