×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Jul 2008
    Posts
    136

    TCP Listen ActiveObject

    Hello,
    I am new bee in symbian.
    I have tried to set up TCP-Listener on Wifi. I have been suceed to established the Active object for the same and code is working fine for first connection.

    Now Problems :
    1. when i start my listener apps ...I can handle one request correctly and code keeps on listening the data from the client connected ... but Now ....
    i. if the Client apps(device ) is shutdown due to lets say power fail at their end, my application is not able to detect that, other device is not connected to it. HOW CAN I DETECT THAT OTHER DEVICE i.e Client is disconnected......?????

    Here is code snippet

    RunL()
    {
    switch (iState)
    {
    case EConnecting:
    {
    // Connected listening socket!
    LogMe(_L8("\nEConnecting\n"));
    ReceiveData();
    break;
    }
    case EWaiting:
    {
    // Returned from receiving data
    // TODO: Do something with received data
    CleanupStack::PopAndDestroy(text);
    // Start expecting next data to be read
    ReceiveData();
    break;
    }

    }

    CTCPListener::ReceiveData()
    {
    // Set state to waiting - for RunL()
    iState = EWaiting;
    // Make async request
    iSock.RecvOneOrMore(iBuffer, 0, iStatus, iLen);
    SetActive();
    }
    Regards
    Swapnil

  2. #2
    Registered User
    Join Date
    Feb 2007
    Location
    Tampere
    Posts
    370

    Re: TCP Listen ActiveObject

    Hi,

    You can use MConnectionMonitorObserver to observe connections.
    Regards

    - MVP
    "Dare To Dream" - A.P.J.Kalam

  3. #3
    Regular Contributor
    Join Date
    Jul 2008
    Posts
    136

    Re: TCP Listen ActiveObject

    Hey Hi,
    Thanks for the reply ....

    between I tried like this ....

    RunL()
    {
    if ( iStatus!=KErrNone )
    {
    LogMe(_L8("\nIn RunL:if iStatus!=KErrNone\n"));
    Cancel();
    StopListener();

    return;
    }
    switch (iState)
    {
    case EConnecting:
    {
    // Connected listening socket!
    LogMe(_L8("\nEConnecting\n"));
    ReceiveData();
    break;
    }
    case EWaiting:
    {
    // Returned from receiving data
    // TODO: Do something with received data
    CleanupStack::PopAndDestroy(text);
    // Start expecting next data to be read
    ReceiveData();
    break;
    }

    }

    CTCPListener::ReceiveData()
    {
    // Set state to waiting - for RunL()
    iState = EWaiting;
    // Make async request
    iSock.RecvOneOrMore(iBuffer, 0, iStatus, iLen);
    if (iStatus == KErrNone )
    {
    LogMe(_L8("\nIn ReceiveData:if iStatus==KErrNone\n"));
    }
    else
    {
    LogMe(_L8("\nIn ReceiveData:if iStatus!=KErrNone\n")); //i m getting "iStatus = -2147483647"
    }
    SetActive();
    }

    Whenever, In RUNL ... it is detecting the error before switch... apps works gr8... close() all socket and try to connect again ... it able to connect again successfully

    But ... many times ... after ReceiveData() ..even though iStatus != KErrNone... and after set active ...many times in RUNL i m not able to catch it ...
    What might be problem
    Thanks
    Swapnil

Similar Threads

  1. [moved] TCP Listen ActiveObject
    By swapnil.bakare@gmail.com in forum Symbian C++
    Replies: 2
    Last Post: 2008-10-24, 14:05
  2. HTTP Post problem on Symbian 9.2 - TCP stuck?
    By bgenady in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2008-08-04, 19:33
  3. TCP server packet receiving problem
    By raj_rr7 in forum Symbian Networking & Messaging (Closed)
    Replies: 9
    Last Post: 2007-07-12, 12:24
  4. emulators stopped working
    By mborg in forum Mobile Web Site Development
    Replies: 1
    Last Post: 2006-11-18, 08:54
  5. Listen and Accept TCP connection
    By msalline in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2004-05-13, 06:01

Posting Permissions

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