×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Feb 2007
    Posts
    30

    Socket closing problem

    Hello dear experts,

    I'm using Rsocket to make bluetooth connection between phone and my application on computer.

    The phone opens a channel(port) and waits for computer to connect.

    When connection established i'm sending and receiving data.
    Sending by:
    Code:
    Socket.Send(.... ,iStatus);
    User::WaitForRequest(iStatus);
    if (iStatus != KErrNone)
    { // handle sending failure
    }
    The problem is when the phone goes out of bluetooth range ,
    The User::WaitForRequest is just stacked and it takes like 30 seconds to WaitForRequest to be completed!! and only then the 'if condition' is handled.

    Can anyone please help me ?? may be wizard_hu ??

    p.s
    i use the send/receive in active object , and i know that this is wrong to use WaitForRequest in AO , i'll change it in future.

    Thanks for any help

  2. #2
    Regular Contributor
    Join Date
    Nov 2007
    Location
    Moratuwa, Sri Lanka
    Posts
    86

    Re: Socket closing problem

    Hi,

    If I am not mistaken, your problem is when it is not in the range, it takes around 30 seconds to handle the WaitForRequest request. Once the socket request is sent, WaitForRequest handles only after an acknowledgment is received. So when the device is in the range it receives the acknowledgment quickly but when it is not in the range, it might wait for certain time period for an acknowledgment then only it decides, it cant send any data. For this it might take around 30 seconds.

    Regards,
    Primal

  3. #3
    Registered User
    Join Date
    Feb 2007
    Posts
    30

    Re: Socket closing problem

    Primal thanks,
    you are totaly right.

    When phone out of BT range with pc the WaitForRequest is just stacked
    for about 30 sec and only then the 'if' statement executed.

    This behaviour is not good for me ! because i want to show info
    message when phone is out of BT range with the pc.

    The situation now is that my 'info message' is shown only after
    30 seconds :-((

    Please any info would be greatly appreceated

  4. #4
    Registered User
    Join Date
    Feb 2007
    Posts
    30

    Re: Socket closing problem

    any help PLEASE ??

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,751

    Re: Socket closing problem

    If you search for *timeout* in the SDK Help, you will find a couple BT-related hits:
    - "bt_sock.h": it has KHCI[Read/Write]PageTimeoutIoctl. You can check what it does (RSocket::Ioctl with/without specifying KSolBtHCI), check the Read-first
    - TBTL2CAPOptions and TL2CapConfig: you can check what these classes are, and where/how they can be used.
    However I have never used anything of the above, so I do not know if they can help.

  6. #6
    Registered User
    Join Date
    Feb 2007
    Posts
    30

    Re: Socket closing problem

    wizard thanks alot for your help, i was waiting your reply

    I'll try your sugestion tomorrow.

    Meanwhile, i realized that just after
    Socket.Send(.... ,iStatus); executed and the phone
    is already out of BT range the iStatus immediately gets -MaxInt.
    That happens before User::WaitFoeRequest executed.

    So i practicaly changed the code to:
    Code:
    Socket.Send(.... ,iStatus);
    if ( iStatus != KErrNone)
      {
       iAcceptedSocket.CancelSend();
       iAcceptedSocket.Close;
       iListeningSocket.Close;
       iServerSocket.Close;
       // restart socket to begin listening incoming connections
      }
    else User::WaitForRequest(iStatus);
    This solves the 30 sec *TimeOut* problem that was caused by User::WaitForRequest , BUT now i just CANT close the socket?!?
    The iAcceptedSocket.Close; takes very long(more than 10 sec to be executed )

    please any info please

  7. #7
    Registered User
    Join Date
    Feb 2007
    Posts
    30

    Re: Socket closing problem

    Also tried to use iAcceptedSocket.ShutDown(...)

Similar Threads

  1. Socket connection problem on N93 device
    By spaniard in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2007-03-29, 22:00
  2. Problem opening Server Socket?
    By camroe in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2005-03-02, 22:27
  3. socket connection problem
    By bhatti81 in forum Mobile Java General
    Replies: 2
    Last Post: 2003-10-08, 14:43
  4. TCP/IP socket connection problem
    By ArunP in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2002-09-19, 10: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
  •  
×