Thanks Peter and Mingfan for your suggestions and code review. I will definately try to improve on it.
  I am currently working on 2.6.15 kernel. and had not applied any patch.
I will like to ask peter that which kernel you are using? Are you facing same problem after patching to latest kernel?
  Do let me know.
  Thanks and regards.
Rupesh

>
>I think the sleep(..) call causes a reschedule and allows the sdpd to
>finish some internal cleanup or so after a close. I got some similar
>behaviour even when connecting to the local sdp data base.
>
>To get your code a little bit faster you should not use the hci_inquiry()
>call. This does not only do the inquiry but also does a name request which
>requires a baseband connection to the remote device. It is much more
>efficient to do the name request as a part of the sdp request if you make
>the sdp request anyway (only one baseband connection for each device).
>
>Further, because most BT chips today allow for inquirie to run in the
>background, you can try to start SDP requests once you receive the BT
>address for a device and not when the inquiry is finished. However, this
>would require some much more complicated code and direct HCI socket
>programming. You may have a look at hcid to get an idea.
>
>Ciao,
>
>Peter