×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    7

    How to close sockets in BTOBEX example?

    I use BTOBEX (BTObjectExchange) Nokia example.
    If I Connect and Disconnect (from menu), then try to Connect again IMMEDIATELY, I always receive message "Maximum OBEX connections in use. Cannot establish connection" (internal from class CObjectExchangeServiceSearcher). However, if I try to Connect after some delay, this message doesn't appear. So looks like the sockets closing asynchronous operation takes time. How can I "force" this opearation to be finished immediately for both CObjectExchangeServiceSearcher and CObexClient, used in the example.
    In "Notepad" application, for example, it is done somehow...

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Posts
    1,213

    RE: How to close sockets in BTOBEX example?

    The Bluetooth link is still up from the previous session. You'll notice this also if you send e.g. an image and then try immediately with another one.

    I think there is nothing you can do programmatically.

    Seppo
    Forum Nokia

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    5

    RE: How to close sockets in BTOBEX example?

    Hi,

    The problem is due to the multithreaded nature of the Symbian OS. The solution is to make the connect and disconnect operation atomic.

    My suggested solution is to create a ConnectSendAndDisconnectL() function that has a flag set to indicate when the message/data delivery is complete.

    So let's say we have a flag called iToDisconnect. We set it to 1 in the ConnectSendAndDisconnectL() function. This function will perform the ConnectL() and SendObjectL() functions together. This you should know how to do.

    In the ObjectExchangeClient.cpp file, there's this case in the switch statement:
    case EWaitingToSend:
    iLog.LogL(_L("Sent object&quot);
    break;

    You can change it to this:
    In the ObjectExchangeClient.cpp file, there's this case in the switch statement:
    case EWaitingToSend:
    iLog.LogL(_L("Sent object&quot);
    if (iToDisconnect == 1)
    {
    // code to disconnect client here
    }
    break;

    The above will disconnect the client immediately after you have sent the data.

    Hope this is useful.

Posting Permissions

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