dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: Winsock error 10049 connect() call failed

  1. #1
    Join Date
    Dec 2011
    Posts
    4

    Winsock error 10049 connect() call failed

    Hi,
    I downloaded an sdk sample program for Bluetooth. I want to discover and connect two bluetooth devices, but i am getting this error when i run the program in client mode--> connect() call failed Winsock error [10049]. When i tried to Google it .. it says "attempt to create a socket with an address not on this machine".

    How do i handle this. I have no experience in socket programming. My aim is to write a Bluetooth application to connect a Bluetooth transmitter to a handheld tablet that has built in WinXP.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,525

    Re: Winsock error 10049 connect() call failed

    From MSDN:
    WSAEADDRNOTAVAIL
    (10049)
    Cannot assign requested address.
    The requested address is not valid in its context. This normally results from an attempt to bind to an address that is not valid for the local machine. This can also result from connect, sendto, WSAConnect, WSAJoinLeaf, or WSASendTo when the remote address or port is not valid for a remote machine (for example, address or port 0).
    So, what is the address used on your local machine?
    What is the address you are trying to connect to?
    Did you try to ping this address?
    Victor Nijegorodov

  3. #3
    Join Date
    Dec 2011
    Posts
    4

    Re: Winsock error 10049 connect() call failed

    Hi VictorN,
    My machine Bluetooth socket address is 00:27:13:33:ed:12
    I tried to connect to my mobile phone device with address 08:18:1a:6a:01:6f
    But it says
    Running in Client mode
    =CRITICAL= | connect() call failed. WSAGetLastError=[10049]

    I had attached the cmd prompt content when i tried to execute the program.
    For reference i had attached the sdk sample program that i downloaded as well.

    How can i handle this error.
    Attached Files Attached Files

  4. #4
    Join Date
    Dec 2011
    Posts
    4

    Re: Winsock error 10049 connect() call failed

    Hi VictorN,
    My machine Bluetooth socket address is 00:27:13:33:ed:12
    I tried to connect to my mobile phone device with address 08:18:1a:6a:01:6f
    But it says
    Running in Client mode
    =CRITICAL= | connect() call failed. WSAGetLastError=[10049]

    -------------------------------------------------------------------------------------------------------------------

    This is the content shown in my command prompt when i tried to execute the program

    --------------------------------------------------------------------------------------------------------------------


    Microsoft Windows [Version 6.1.7600]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.

    C:\Users\admin\Desktop\Bluetooth_socket_programs\Bluetooth\SdkSample>cd Debug

    C:\Users\admin\Desktop\Bluetooth_socket_programs\Bluetooth\SdkSample\Debug>SdkSample.exe -a08:18:1a:6a:01:6f -c0


    Winsock Version: 2.2
    Enumerating available protocols:
    Index #0 - name: 'MSAFD Tcpip [TCP/IP]', type: 1, proto: 6
    Index #1 - name: 'MSAFD Tcpip [UDP/IP]', type: 2, proto: 17
    Index #2 - name: 'MSAFD Tcpip [TCP/IPv6]', type: 1, proto: 6
    Index #3 - name: 'MSAFD Tcpip [UDP/IPv6]', type: 2, proto: 17
    Index #4 - name: 'RSVP TCPv6 Service Provider', type: 1, proto: 6
    Index #5 - name: 'RSVP TCP Service Provider', type: 1, proto: 6
    Index #6 - name: 'RSVP UDPv6 Service Provider', type: 2, proto: 17
    Index #7 - name: 'RSVP UDP Service Provider', type: 2, proto: 17
    Index #8 - name: 'MSAFD RfComm [Bluetooth]', type: 1, proto: 3
    Index #9 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{7FEB11CA-502A-4E48-9B41-E
    E8A21D4FFB1}] SEQPACKET 34', type: 5, proto: -34
    Index #10 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{7FEB11CA-502A-4E48-9B41-
    EE8A21D4FFB1}] DATAGRAM 34', type: 2, proto: -34
    Index #11 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{35B539D0-8BB1-4A9F-B3A8-
    E058B3AA8313}] SEQPACKET 33', type: 5, proto: -33
    Index #12 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{35B539D0-8BB1-4A9F-B3A8-
    E058B3AA8313}] DATAGRAM 33', type: 2, proto: -33
    Index #13 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{169B1476-AA9F-471C-9CE6-
    F53C305062A5}] SEQPACKET 39', type: 5, proto: -39
    Index #14 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{169B1476-AA9F-471C-9CE6-
    F53C305062A5}] DATAGRAM 39', type: 2, proto: -39
    Index #15 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{683866C8-6BF9-41A6-B3F2-
    1008647404BE}] SEQPACKET 29', type: 5, proto: -29
    Index #16 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{683866C8-6BF9-41A6-B3F2-
    1008647404BE}] DATAGRAM 29', type: 2, proto: -29
    Index #17 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{532E40F9-255D-4608-AD11-
    873CC08F532F}] SEQPACKET 28', type: 5, proto: -28
    Index #18 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{532E40F9-255D-4608-AD11-
    873CC08F532F}] DATAGRAM 28', type: 2, proto: -28
    Index #19 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{87D5E996-9EEF-46EB-A80B-
    6AF1AD6F4416}] SEQPACKET 8', type: 5, proto: -8
    Index #20 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{87D5E996-9EEF-46EB-A80B-
    6AF1AD6F4416}] DATAGRAM 8', type: 2, proto: -8
    Index #21 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{DF3A17C9-482D-469E-91C1-
    FFB2AFBE2806}] SEQPACKET 35', type: 5, proto: -35
    Index #22 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{DF3A17C9-482D-469E-91C1-
    FFB2AFBE2806}] DATAGRAM 35', type: 2, proto: -35
    Index #23 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{398FC280-FB67-4BAE-8B7A-
    680F58727B4C}] SEQPACKET 19', type: 5, proto: -19
    Index #24 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{398FC280-FB67-4BAE-8B7A-
    680F58727B4C}] DATAGRAM 19', type: 2, proto: -19
    Index #25 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{6B519E2F-EC9E-49C7-979F-
    EF0E27ECEC6B}] SEQPACKET 27', type: 5, proto: -27
    Index #26 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{6B519E2F-EC9E-49C7-979F-
    EF0E27ECEC6B}] DATAGRAM 27', type: 2, proto: -27
    Index #27 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{CF0D3663-D29A-48CB-9197-
    E42F5A014960}] SEQPACKET 32', type: 5, proto: -32
    Index #28 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{CF0D3663-D29A-48CB-9197-
    E42F5A014960}] DATAGRAM 32', type: 2, proto: -32
    Index #29 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{2C033174-9325-4393-83E8-
    50C1F98814BC}] SEQPACKET 30', type: 5, proto: -30
    Index #30 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{2C033174-9325-4393-83E8-
    50C1F98814BC}] DATAGRAM 30', type: 2, proto: -30
    Index #31 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{F71890FA-BC30-4CDD-ADE0-
    415689B20E1F}] SEQPACKET 26', type: 5, proto: -26
    Index #32 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{F71890FA-BC30-4CDD-ADE0-
    415689B20E1F}] DATAGRAM 26', type: 2, proto: -26
    Index #33 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{369C5739-0512-4746-8112-
    C6903AA9765B}] SEQPACKET 24', type: 5, proto: -24
    Index #34 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{369C5739-0512-4746-8112-
    C6903AA9765B}] DATAGRAM 24', type: 2, proto: -24
    Index #35 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{CDDB9D1E-03AD-41A8-9928-
    DD1D4C6D18FF}] SEQPACKET 25', type: 5, proto: -25
    Index #36 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{CDDB9D1E-03AD-41A8-9928-
    DD1D4C6D18FF}] DATAGRAM 25', type: 2, proto: -25
    Index #37 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{682D3A39-CADD-4FD0-AD4F-
    A6D7AF73235F}] SEQPACKET 21', type: 5, proto: -21
    Index #38 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{682D3A39-CADD-4FD0-AD4F-
    A6D7AF73235F}] DATAGRAM 21', type: 2, proto: -21
    Index #39 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{926E544C-A409-43EA-AFC2-
    70D1E07ACA9A}] SEQPACKET 20', type: 5, proto: -20
    Index #40 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{926E544C-A409-43EA-AFC2-
    70D1E07ACA9A}] DATAGRAM 20', type: 2, proto: -20
    Index #41 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{777E97DA-F56A-4713-9035-
    5FA4F7D785C3}] SEQPACKET 17', type: 5, proto: -17
    Index #42 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{777E97DA-F56A-4713-9035-
    5FA4F7D785C3}] DATAGRAM 17', type: 2, proto: -17
    Index #43 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{C68547E4-5927-4A57-8004-
    B69B0C633FB9}] SEQPACKET 18', type: 5, proto: -18
    Index #44 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{C68547E4-5927-4A57-8004-
    B69B0C633FB9}] DATAGRAM 18', type: 2, proto: -18
    Index #45 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{32C92B74-D5EB-4B86-A664-
    FEB2BEF8D1FC}] SEQPACKET 9', type: 5, proto: -9
    Index #46 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{32C92B74-D5EB-4B86-A664-
    FEB2BEF8D1FC}] DATAGRAM 9', type: 2, proto: -9
    Index #47 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{DD874799-EB55-4AFC-BF9F-
    69F9FC7585BD}] SEQPACKET 0', type: 5, proto: -2147483648
    Index #48 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{DD874799-EB55-4AFC-BF9F-
    69F9FC7585BD}] DATAGRAM 0', type: 2, proto: -2147483648
    Index #49 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{4CE5EE5E-3A8A-4CAC-87CC-
    19CD4CEBEB17}] SEQPACKET 11', type: 5, proto: -11
    Index #50 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{4CE5EE5E-3A8A-4CAC-87CC-
    19CD4CEBEB17}] DATAGRAM 11', type: 2, proto: -11
    Index #51 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{101BBB85-62F9-4B49-9774-
    772B258579A0}] SEQPACKET 5', type: 5, proto: -5
    Index #52 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{101BBB85-62F9-4B49-9774-
    772B258579A0}] DATAGRAM 5', type: 2, proto: -5
    Index #53 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{4AA42CC5-9D63-4BFE-BEB3-
    FF2DA2B8A6AE}] SEQPACKET 15', type: 5, proto: -15
    Index #54 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{4AA42CC5-9D63-4BFE-BEB3-
    FF2DA2B8A6AE}] DATAGRAM 15', type: 2, proto: -15
    Index #55 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{48667973-C457-4A9A-BD75-
    A79301314C33}] SEQPACKET 16', type: 5, proto: -16
    Index #56 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{48667973-C457-4A9A-BD75-
    A79301314C33}] DATAGRAM 16', type: 2, proto: -16
    Index #57 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{7CE367EF-7A70-4815-AD77-
    F49F774401C6}] SEQPACKET 14', type: 5, proto: -14
    Index #58 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{7CE367EF-7A70-4815-AD77-
    F49F774401C6}] DATAGRAM 14', type: 2, proto: -14
    Index #59 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{C576F107-CC02-45E5-B58A-
    2E08DBF87E3C}] SEQPACKET 13', type: 5, proto: -13
    Index #60 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{C576F107-CC02-45E5-B58A-
    2E08DBF87E3C}] DATAGRAM 13', type: 2, proto: -13
    Index #61 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{F142D991-1F20-4FBF-BED6-
    CD0FEEDA647C}] SEQPACKET 12', type: 5, proto: -12
    Index #62 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{F142D991-1F20-4FBF-BED6-
    CD0FEEDA647C}] DATAGRAM 12', type: 2, proto: -12
    Index #63 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{24154765-C8D2-4D02-8AFD-
    2A01C777B33A}] SEQPACKET 7', type: 5, proto: -7
    Index #64 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{24154765-C8D2-4D02-8AFD-
    2A01C777B33A}] DATAGRAM 7', type: 2, proto: -7
    Index #65 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{7C643496-A1B4-4EC4-A70B-
    9B08003F35C7}] SEQPACKET 4', type: 5, proto: -4
    Index #66 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{7C643496-A1B4-4EC4-A70B-
    9B08003F35C7}] DATAGRAM 4', type: 2, proto: -4
    Index #67 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{D5A27399-9AA1-45C8-B047-
    3E5B67FCB241}] SEQPACKET 3', type: 5, proto: -3
    Index #68 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{D5A27399-9AA1-45C8-B047-
    3E5B67FCB241}] DATAGRAM 3', type: 2, proto: -3
    Index #69 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{A4F7DA64-B062-4579-8D9B-
    3EF96D1A243F}] SEQPACKET 31', type: 5, proto: -31
    Index #70 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip6_{A4F7DA64-B062-4579-8D9B-
    3EF96D1A243F}] DATAGRAM 31', type: 2, proto: -31
    Index #71 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip_{7FEB11CA-502A-4E48-9B41-E
    E8A21D4FFB1}] SEQPACKET 37', type: 5, proto: -37
    Index #72 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip_{7FEB11CA-502A-4E48-9B41-E
    E8A21D4FFB1}] DATAGRAM 37', type: 2, proto: -37
    Index #73 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip_{87D5E996-9EEF-46EB-A80B-6
    AF1AD6F4416}] SEQPACKET 10', type: 5, proto: -10
    Index #74 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip_{87D5E996-9EEF-46EB-A80B-6
    AF1AD6F4416}] DATAGRAM 10', type: 2, proto: -10
    Index #75 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip_{DF3A17C9-482D-469E-91C1-F
    FB2AFBE2806}] SEQPACKET 36', type: 5, proto: -36
    Index #76 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip_{DF3A17C9-482D-469E-91C1-F
    FB2AFBE2806}] DATAGRAM 36', type: 2, proto: -36
    Index #77 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip_{F71890FA-BC30-4CDD-ADE0-4
    15689B20E1F}] SEQPACKET 23', type: 5, proto: -23
    Index #78 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip_{F71890FA-BC30-4CDD-ADE0-4
    15689B20E1F}] DATAGRAM 23', type: 2, proto: -23
    Index #79 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip_{24154765-C8D2-4D02-8AFD-2
    A01C777B33A}] SEQPACKET 6', type: 5, proto: -6
    Index #80 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip_{24154765-C8D2-4D02-8AFD-2
    A01C777B33A}] DATAGRAM 6', type: 2, proto: -6
    Index #81 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip_{7C643496-A1B4-4EC4-A70B-9
    B08003F35C7}] SEQPACKET 1', type: 5, proto: -1
    Index #82 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip_{7C643496-A1B4-4EC4-A70B-9
    B08003F35C7}] DATAGRAM 1', type: 2, proto: -1
    Index #83 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip_{D5A27399-9AA1-45C8-B047-3
    E5B67FCB241}] SEQPACKET 2', type: 5, proto: -2
    Index #84 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip_{D5A27399-9AA1-45C8-B047-3
    E5B67FCB241}] DATAGRAM 2', type: 2, proto: -2
    Index #85 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip_{A4F7DA64-B062-4579-8D9B-3
    EF96D1A243F}] SEQPACKET 22', type: 5, proto: -22
    Index #86 - name: 'MSAFD NetBIOS [\Device\NetBT_Tcpip_{A4F7DA64-B062-4579-8D9B-3
    EF96D1A243F}] DATAGRAM 22', type: 2, proto: -22

    Commencing Bluetooth operations:
    *INFO* | Running in Client mode

    =CRITICAL= | connect() call failed. WSAGetLastError=[10049]

  5. #5
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: Winsock error 10049 connect() call failed

    Is this the SDK sample called bthcxn.cpp?

    If so, then before you run in the client mode (which is the thing that calls connect() with failure code 10049), you must first be running a separate instance in the server mode. And when running in the client mode, you must pass in the IPv6 loopback address of 0:0:0:0:0:0:0:1

    You can find more information on this by reading the "help" on the command line options.

    Mike

  6. #6
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: Winsock error 10049 connect() call failed

    Quote Originally Posted by MACH09 View Post
    ... This is the content shown in my command prompt when i tried to execute the program ...
    I recognize that as the code I modified for another thread (from 2008), based on the SDK example. The modified code can be found in this thread: "Bluetooth socket error" at http://www.codeguru.com/forum/showth...72#post1688625

    Quote Originally Posted by MACH09 View Post
    ... I tried to connect to my mobile phone device with address 08:18:1a:6a:01:6f ...
    Does your mobile phone have an instance of the server running on it? If it does not, then there is no way that the client could connect, for the reason that the mobile phone does not have a server for the client to connect to.

    Mike

  7. #7
    Join Date
    Dec 2011
    Posts
    4

    Re: Winsock error 10049 connect() call failed

    Thanks Mike..!!! Yes my mobile phone doesn't have a instance of the server.
    I ran the same application from another PC (one PC as server mode and another as client mode).
    I tried the edited code given in the link. But i'm still getting the same error.

    -
    Mach

  8. #8
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: Winsock error 10049 connect() call failed

    Quote Originally Posted by MACH09 View Post
    ...I ran the same application from another PC (one PC as server mode and another as client mode)..... But i'm still getting the same error.
    You might be encountering firewall or other network issues. Try running two instances of the program on the same machine (one client and the other server) and using the loopback address to connect.

    Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)