Bluetooth bind() fails with WSANETDOWN

Discussion in 'Wireless Networking' started by Brown Dwarf, Apr 10, 2006.

  1. Brown Dwarf

    Brown Dwarf Guest

    Hello there,
    This is the first time I'm probramming for bluetooth.
    I installed a USB bluetooth device and the software comes with it works
    great, detecting other devices and communicates.

    Now I'm developing an bluetooth application to run in server mode (using
    WSASetService).
    But it fails at bind() with WSANETDOWN. Any idea how to troubleshoot this ??

    Platform: WindowsXp-SP2, MSVC6

    SOCKET s = ::socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM);
    DWORD lastError = ::WSAGetLastError();
    if (s == INVALID_SOCKET)
    {
    printf("Failed to get bluetooth socket! %s\n",
    GetLastErrorMessage(lastError));
    exit(1);
    }

    SOCKADDR_BTH sbth;
    memset(&sbth, 0, sizeof(sbth));
    sbth.addressFamily = AF_BTH;
    sbth.btAddr = 0;
    sbth.port = BT_PORT_ANY;

    if (bind(s, (const sockaddr*)&sbth, sizeof(SOCKADDR_BTH)) == SOCKET_ERROR)
    // <<------ here is the problem
    {
    lastError = ::WSAGetLastError(); // always WSANETDOWN
    printf("Failed to bind bluetooth socket! %s\n",
    GetLastErrorMessage(lastError));
    exit(1);
    }
    Brown Dwarf, Apr 10, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Um9zbWFuIENvbXB1dGluZw==?=

    Cannot bind to tcp/ip

    =?Utf-8?B?Um9zbWFuIENvbXB1dGluZw==?=, Sep 23, 2005, in forum: Wireless Networking
    Replies:
    1
    Views:
    2,596
    Malke
    Sep 23, 2005
  2. Replies:
    1
    Views:
    671
  3. jacksu
    Replies:
    0
    Views:
    1,155
    jacksu
    Mar 2, 2004
  4. Ant

    70-219 BIND Question?

    Ant, Jun 16, 2004, in forum: MCSE
    Replies:
    3
    Views:
    1,505
    Kurt Hudson [MVP DS]
    Jun 17, 2004
  5. Bodo

    ICS fails with with Bluetooth Network

    Bodo, May 12, 2006, in forum: Wireless Networking
    Replies:
    0
    Views:
    449
Loading...

Share This Page