Bluetooth socket bind fails...!


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 (192.168.50.1) 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 192.168.50.1 - works fine
    * Tried different values for port number - same error
    * Tried with NO USB hardware plugged in - same result !!


Questions:
    ? 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 ?

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



<code>
SOCKET
openBTServerSocket(int port){
    DWORD lastError;

    SOCKET s = ::socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM);
    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;
}
</code>
LVL 8
mxjijoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mxjijoAuthor Commented:

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
0
EE_AutoDeleterCommented:
mxjijo,
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.

EE_AutoDeleter
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.