.NET Components for Mobility

Socket Exception on Widcomm

Last post 09-22-2010 2:03 PM by cttm. 22 replies.
Page 1 of 2 (23 items) 1 2 Next >
Sort Posts: Previous Next
  • 08-26-2010 6:42 AM

    • cttm
    • Top 50 Contributor
    • Joined on 08-12-2010
    • Posts 16

    Socket Exception on Widcomm

    Hi all, I am having trouble getting a simple connection on a Widcomm machine to work. It works fine on my laptop that uses the Windows stack. Here is the small part of the code. SelectBluetoothDeviceDialog sbdd = new SelectBluetoothDeviceDialog(); if (sbdd.ShowDialog() == DialogResult.OK) { BluetoothSecurity.PairRequest(sbdd.SelectedDevice.DeviceAddress, "1234"); BluetoothEndPoint endpoint = new BluetoothEndPoint(sbdd.SelectedDevice.DeviceAddress, BluetoothService.SerialPort); if (!BC.Connected) { BC.Connect(endpoint); //DISCOVERY_RESULT_WIDCOMM SOCKET EXCEPTION WAS UNHANDLED HERE } It's error shows " DISCOVERY_RESULT = OTHER_ERROR = 0x5; ServiceRecordsGetResult. BTW, how do I get the "ENTER" to work in the forums. Don't know how to prevent my posts from looking like crap. Thanks all, Chris
    Filed under:
  • 08-30-2010 8:13 AM In reply to

    Re: Socket Exception on Widcomm

    So we asked the remote device's SDP service whether it was running the selected service and it returned that error code, and the Widcomm documentation doesn't give any further information about what that error code means; the document just shows this table

    Table 4: DISCOVERY_RESULT

    DISCOVERY_RESULT Value Meaning
    DISCOVERY_RESULT_SUCCESS Discovery has completed successfully.
    DISCOVERY_RESULT_CONNECT_ERR Could not connect to remote device.
    DISCOVERY_RESULT_CONNECT_REJ Remote device rejected the connection.
    DISCOVERY_RESULT_SECURITY Security (authentication) failed.
    DISCOVERY_RESULT_BAD_RECORD Remote Service Record Error.
    DISCOVERY_RESULT_OTHER_ERROR Other error.

    Does it always occur, does it work connecting to other devices?

  • 08-31-2010 6:05 AM In reply to

    • cttm
    • Top 50 Contributor
    • Joined on 08-12-2010
    • Posts 16

    Re: Socket Exception on Widcomm

    Hi Alan, Thanks for the reply. I've updated my bluetooth device driver and now it gives me a different error. When I try to connect using BluetoothService.SerialPort, it gives me a NoResultCodeWidcommSocketException; PortLookup_NoneRfcomm error. Just to give you a bit more detail on the system I'm testing it on. I'm using Windows XP Service pack 3, my bluetooth device is a Lenovo ThinkPad Bluetooth with Enhanced Data Rate II running on Broadcom driver 5.5.0.7600. I included the InTheHand.Net.Personal.dll v2.5.0.0 as well as the 32feetWidcomm.dll v2.5.0.0 in the debug folder of the application. The Btwapi.dll is not present in the system32 folder but I tested putting the btwapi.dll v 5.1.0.3100 as well as v6.2.1.2600 but it does not make any difference. Hope to hear from you soon. Thank you. Best regards, Chris P.S. Could you please teach me how to format my posts better? Sorry if it looks like crap.
  • 08-31-2010 7:56 AM In reply to

    • cttm
    • Top 50 Contributor
    • Joined on 08-12-2010
    • Posts 16

    Re: Socket Exception on Widcomm

    Another note, I am unable to connect to any device using this few lines of code. So I'm guessing there's something wrong with the dependencies/driver? After I updated the driver for the first time, it comes up with an error when I try to search for new updates. Hope this helps.
  • 09-01-2010 3:21 AM In reply to

    Re: Socket Exception on Widcomm

    There doesn't seem anything wrong with dependencies, there would be a different and earlier error if there was a problem there,  The docs say error PortLookup_Zero means "No Service Record with the specified Service Class UUID."  So it looks to us that there is no SerialPort service on the remote PC.

    Do you need to run HyperTerminal (or similar) and open the "incoming" virtual serial port to get the PC to advertise that service -- that's how it is on the MSFT stack.

    You say the program works on your PC with the MSFT stack, so connecting to the remote PC to the SerialPort service works from there?

  • 09-01-2010 4:36 AM In reply to

    • cttm
    • Top 50 Contributor
    • Joined on 08-12-2010
    • Posts 16

    Re: Socket Exception on Widcomm

    Thanks for the kind replies Alan. Truly appreciate it. It's actually a tool with a bluetooth module that I am trying to connect to. I use an application on my PC to connect to the Serial Port service, send bytes of data, and receive acknowledgement from the tool. However, it does not work on my laptop which uses the Widcomm stack. I don't think I can run a HyperTerminal on the tool though. But if I can connect using my PC with the MSFT stack, I don't see how the tool can not have a serialport service, if you see what I mean? Thanks again Alan. Hope to hear from you soon. Cheers, Chris
  • 09-05-2010 8:39 AM In reply to

    Re: Socket Exception on Widcomm

    Ahh OK. Do you run the applicationusing 32feet.NET on the MSFT PC, does it work there?

    Can you run the SdpBrowser on both PCs and do an SDP query for service L2capProtocol, run discovery, select the module, do the SDP query.  Are there a different number of services reported?  Does a service with class id SerialPort appear only on the MSFT PC?

  • 09-06-2010 7:04 AM In reply to

    • cttm
    • Top 50 Contributor
    • Joined on 08-12-2010
    • Posts 16

    Re: Socket Exception on Widcomm

    Hi Alan, it's working now. I tried out a different Widcomm 2.5 dll ( the one in r49716 folder) and it's working now. May I know what's the difference between the dlls and why are there so many dlls of the same version but different sizes? Will different PCs require different Widcomm dlls? And if I were to use this application on a new PC, besides needing the Widcomm and In The Hand Dlls, am I right that I have to install the vcredist_x86 as well as include the btwapi.dll in the system32 folder (if it doesn't already exist)? And if the btwapi.dll already exists, will it always work or do I need to get the correct version? Thank you
  • 09-08-2010 7:41 AM In reply to

    Re: Socket Exception on Widcomm

    I'm in a rush at the moment have a read of the user guide and the widcomm doc in the release (and updated version in the repository) for information on the horrible dependencies on native code on Win32. :-(  (Maybe also see http://32feetnetdev.wordpress.com/2009/12/14/new-widcomm-dependency/ for how the depencies change depending on where/when the project is compiled)

    On installing onto other machines.  As of 2.5, we no longer need btwapi.dll, see  the widcomm doc (I seem not to have updated the user guide in that release!).  To ensure the necessary VisualC++ library version is present check that in your installe, manually/or part of a script you could run its installer .exe, or the Windows Installer stuff can help, there are merge modules installed with VC++ to tell the installer to check and install if necessary the correct version.  (I thought about creating a merge module, that referenced the correct merge module http://32feet.codeplex.com/workitem/25999 , but it didn't seem to be of little help in the end).

  • 09-08-2010 8:53 AM In reply to

    • cttm
    • Top 50 Contributor
    • Joined on 08-12-2010
    • Posts 16

    Re: Socket Exception on Widcomm

    Update: 1. btwapi.dll is still needed on 2.5. Does not work when I take it out. 2. Different PCs require different dlls. Is there a way to identify which dll is needed? Or is there a dll that works for most if not all PCs. 3. Do you mind letting me know what kind of system you test on? and what size of dll do you use? Thank you and only reply if you can find the time to. Appreciate it!
  • 09-09-2010 10:41 AM In reply to

    Re: Socket Exception on Widcomm

    You're not using 2.5 now as I remember but instead some old 32feetWidcomm DLL from the respository.  As shown below, the 2.5 DLL links to the always-present wbtapi.dll file and not the btwapi.dll (that is often not installed by Widcomm).

    Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
    Copyright (C) Microsoft Corporation.  All rights reserved.

    Dump of file 2.5_0125\Assemblies\XP2\Widcomm x86\32feetWidcomm.dll
    File Type: DLL

      Image has the following dependencies:
        MSVCR80.dll
        WS2_32.dll
        KERNEL32.dll
        USER32.dll
        ADVAPI32.dll

      Image has the following delay load dependencies:
        wbtapi.dll

      ...

    So it seems likely that the problem with different DLLs on different PC is that horrible dependency issue from VisualC++.  Put the Test32feetWidcommWin32.exe file in the same folder as your app (and where the 32feetWidcomm.dll file is), run it, what does it report?  I presume each PC will have a different set of VisualC++ library versions.  I don't know any way to detect that from managed code.  It seems that all native code needs to be installed by an installer which handles installing that dependency and others. :-(

    Let me know if I can provide more help.

  • 09-10-2010 10:41 AM In reply to

    • cttm
    • Top 50 Contributor
    • Joined on 08-12-2010
    • Posts 16

    Re: Socket Exception on Widcomm

    Hi Alan, Once again, thanks for replying. The Test32feetWidcommWin32.exe file ran fine on both machines. 32feet.NET using Widcomm stack dependency checker tool. We will attempt to load and use the 32feetWidcomm support. " Did find 32feetWidcomm.dll file. :-) Did find 32feetWidcomm.dll DLL. :-) DLL found at >>C:\Desktop\WindowsApplication2\bin\Debug\32feetWidcomm.dll< " I ploughed through the forums and I've now gotten the app to connect to the tool by using endpoint = new BluetoothEndPoint(sbdd.SelectedDevice.DeviceAddress, BluetoothService.Empty, 1); BC.Connect(endpoint); However, is this method advisable? Will this cause any problems when dealing such as port number 1 not being available on other PCs? Is there any method to search for available ports programatically? Cheers, Chris
  • 09-11-2010 9:38 AM In reply to

    Re: Socket Exception on Widcomm

    Phew.  Its a real pain the Widcomm dependencies but I can't see a good workaround apart from having the installer check the dependencies.  Suggestions are welcomed.  I suppose I could include the redist package in the download but it might be quite big...

    Anyway.  From a couple of user reports we seem now to be having a problem making connections using Widcomm, it seems that the SDP lookup phase is failing.  It works here on my PC (XP with Widcomm as Belkin 3.0.1.912).  What's your platform?  Do you have a debugger e.g. VS installed on a machine with Widcomm?

     

  • 09-13-2010 4:01 AM In reply to

    • cttm
    • Top 50 Contributor
    • Joined on 08-12-2010
    • Posts 16

    Re: Socket Exception on Widcomm

    Hi Alan, Hope you had a great weekend. I tested on few machines. The first one is a Windows 7 with MSFT. Works fine. Another is an XP SP3 with Widcomm using integrated bluetooth. Worked fine with BluetoothService.SerialPort using the old Widcomm dll. Now it works using only COM port 1 with latest Widcomm dll. Another machine is an XP SP3 with MSFT, but I had to install Widcomm drivers onto it as the dongles I use with that machine (Rocketfish Bluetooth adapter from BestBuy) do not work with the MSFT. This machine too only works for COM port 1 with the latest Widcomm dll. I have VS installed on the first two machines. Hope this helps. Will it be a problem if I used COM port 1 for my application? Will it stop any other services? Thanks for your replies and keep up the very good work. Best regards, Chris
  • 09-13-2010 8:20 AM In reply to

    Re: Socket Exception on Widcomm

    (BTW on terminology, the port 1 is the "RFCOMM" port number, like a TCP/IP port number (the real term is RFCOMM Service Channel Number IIRC but we don't normally use that term)).

    Can you run dumpbin on the two 32feetWidcomm.dlls you are using, presumably the one that works is linked to (/imports) btwapi.dll and the one that doesn't links to wbtapi.dll?  I'll also have to check what version of Widcomm I'm linking to.  Apparently there's something happening in that linkage.

    Can you download the source from http://32feet.codeplex.com, compile the main library (e.g. add the project to your own solution), and have your program run with it.  Set a breakpoint in method FillInPort_ServiceDiscoveryCallback in class InTheHand.Net.Bluetooth.Widcomm.WidcommBluetoothClient.  On Connect, presumably we do get to call "int[ ports = recBuf.Hack_GetPorts();", but presumably all the elements in the result array are negative one?  Then enable "unmanaged debugging" in your app's project and run again, this time step into Hack_GetPorts and into the native code.  What does the native call to Widcomm result in, what result, what port output?

    Many thanks
Page 1 of 2 (23 items) 1 2 Next >
Copyright © 2001-2012 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy. OrcsWeb's Windows Cloud Server Hosting