none
No connection could be made because the target machine actively refused it RRS feed

  • Question

  • I am connecting Bluetooth printer from window mobile application.

    I am developing Application for Windows Mobile 6.1.

    I am able to coonnect it using following code.

    using (Socket socket = new Socket(AddressFamily32.Bluetooth, SocketType.Stream, BluetoothProtocolType.RFComm))
    {                        
    BluetoothEndPoint a = new BluetoothEndPoint(DeviceAddress, BluetoothService.SerialPort);                        
    socket.Connect(a);                        
    socket.Close();                     
    }

    It is able to connect first time, but it fails to connect second time. After, that it is not connecting again.

    When I restart printer, then only I am able to connect.

    In above code, BluetoohEndPoint, DeviceAddress is taken from 32feet.Net library

    using 32feet.Net method also, I am getting same error.

    Monday, June 23, 2014 1:36 PM

All replies

  • Hi Harsh10,

    It is able to connect first time, but it fails to connect second time. After, that it is not connecting again.

    -> Looks like your code works fine at least for one time.

    When I restart printer, then only I am able to connect.

    -> Control source not release?

    And can you connect correctly if you do not use some third party code?

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, June 24, 2014 7:18 AM
    Moderator
  • Hello,

    In my code, only BluetoohEndPoint & DeviceAddress were taken from 32feet.Net library

    When connecting to socket, I am using object of BluetoohEndPoint , in that BluetoohEndPoint  class is inherited from EndPoint.

    I am not using 3rd party code in Socket's connect & close method.

    Tuesday, June 24, 2014 9:27 AM