Bluetooth socket bind fails...!

Posted on 2006-04-13
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 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
    LVL 8

    Author Comment


    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

    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
    For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    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.…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now