Bluetooth socket bind fails...!

Posted on 2006-04-13
Medium Priority
Last Modified: 2013-12-03

Hi there,
    I installed a Bluesoleil USB bluetooth adapter on my windows XP (SP2) box. Installed the software
came with it and it works great ! It can detect other BT devices nearby and can communicate with them.
I can also see a new network adapter (tcp stack) getting added to the system (in network connections window).
It has a new IP address ( and I can ping it. Basically everything looks fine.

    Now I want to write a bluetooth server application. I took the sample from platform SDK and referred
http://www.lenholgate.com/archives/000102.html and wrote the following simple to open a BT socket
and bind. But it never succeeds. bind() call always return WSANETDOWN (10050, dead network).
I have no idea how to get around this.

Other tests/observations:
    * Tried opening/binding a INET socket against - works fine
    * Tried different values for port number - same error
    * Tried with NO USB hardware plugged in - same result !!

    ? How do I debug this ? (apparently)
    ? I noticed in ws2bth.h AF_BT = 32 (Bluetooth address family), but in Winsock2.h AF_MAX (maximum AF_ ) = 26  !!
       What does it tell me ?
    ? Any useful samples/articles available ?

    Windows XP (SP2), MSVC 6, Bluesoleil bluetooth USB adapter

openBTServerSocket(int port){
    DWORD lastError;

    if (s == INVALID_SOCKET) {
        lastError = ::WSAGetLastError();
        printf("Failed to get bluetooth socket! %s\n", GetLastErrorMessage(lastError));
        return INVALID_SOCKET;

    SOCKADDR_BTH sbth;
    memset(&sbth, 0, sizeof(SOCKADDR_BTH));
    sbth.addressFamily = AF_BTH;
    sbth.btAddr = 0;    
    sbth.port = 0;        // tried BT_PORT_ANY as well
    if (bind(s, (const sockaddr*)&sbth, sizeof(SOCKADDR_BTH)) == SOCKET_ERROR){
        lastError = ::WSAGetLastError(); //  <<--------------------------------------------------- ERROR 10050
        printf("Failed to bind bluetooth socket! %s\n", GetLastErrorMessage(lastError));
        return INVALID_SOCKET;

    return s;
Question by:mxjijo

Author Comment

ID: 16449832

Okay.. I found the answer...

It was the Bluesoleil software..
I uninstalled the software and let windows do pnp.
It detected the device and now my program works great!!

thanks for loooking at it.

PS: Admin, please close this posting

Accepted Solution

EE_AutoDeleter earned 0 total points
ID: 16634847
Because you have presented a solution to your own problem which may be helpful to future searches, this question is now PAQed and your points have been refunded.


Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question