Winsock error on rebuilding BT connection (PC to NXT)

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

Winsock error on rebuilding BT connection (PC to NXT)

Postby xglyphic » Thu Mar 03, 2011 1:11 am

Hi everyone,

I searched throughout the Forums but i could not find an error like this. Also google or other search engines didnt really help me out.

The problem i have is on a Windows 7 64-bit PC. Everything is working fine (samples etc. ) and even the code posted below does what it should do (Connect to a specified NXT).

But, after i disconnect again ( comm.close(); ) and close the program,
on a new start i cannot execute this code again.

It gets me a

"Failed to connect; [10064] A socket operation failed because the destination host was down."

restarting does solve the problem, but I dont want to restart the PC again every time ;)

The other workaround that might help finding a solution was starting the programm with an admin-console. Indeed, this helps, but only once. After that however, im able to start it from a normal console. Either way, since i use the program for several things, i dont want to do this.

Any help on this would be really appreciated. If i forgot to mention something, please ask.

The code
Code: Select all
  ConnectionReader cr = new ConnectionReader(name);
            String mac = null;
            try {
                mac = cr.readFile();
            } catch (RuntimeException e ) {
                e.printStackTrace();
            }
            NXTInfo nxtInfo = new NXTInfo(NXTCommFactory.BLUETOOTH, name, mac);

            try {
                comm = NXTCommFactory.createNXTComm(NXTCommFactory.BLUETOOTH);
                System.out.print(comm.available());
                connected = comm.open(nxtInfo);
                if (connected) { System.out.println("Connected");
                    output = new DataOutputStream(comm.getOutputStream());
                    input = new DataInputStream(comm.getInputStream());
                    return true;
                } else {
                    System.out.println("Could not connect");
                    return false;
                }
            } catch (NXTCommException e) {
                System.out.println("Could not connect");
                System.out.println(e.getMessage());
                comm.close();
                throw new RuntimeException("Failure on building the Connection.")
            }

   }
xglyphic
New User
 
Posts: 3
Joined: Thu Mar 03, 2011 1:01 am

Postby gloomyandy » Thu Mar 03, 2011 1:21 am

Hi,
I've never seen this problem (and I use Bluetooth a lot on several different systems). You didn't say what sort of Bluetooth device you are using or which Bluetooth stack... In general if you can use the Microsoft stack...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4174
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby xglyphic » Thu Mar 03, 2011 10:24 am

I didnt have this error in the beginning, and im quite sure its something hardware-near. So i do understand when no one here can help me out..

Stack is a bluecove (v2.1.0) stack over winsock.
Bluetooth hardware is a csr bluetooth 2.0 chip in a dongle (manufacturer unknown)

The errorcode 10064 is a Winsock error code.
xglyphic
New User
 
Posts: 3
Joined: Thu Mar 03, 2011 1:01 am

Postby xglyphic » Thu Mar 03, 2011 3:37 pm

Error resolved!

By making sure the connection is established before via other connections data is send.
xglyphic
New User
 
Posts: 3
Joined: Thu Mar 03, 2011 1:01 am

Re: Winsock error on rebuilding BT connection (PC to NXT)

Postby gsauce » Wed May 02, 2012 3:31 pm

hi~~
maybe im out of the topic but i want to ask about establishing BT connection using Bluecove.

i get the same error as above "Exception: Failed to connect; [10064] A socket operation failed because the destination host was down."

i want to establish BT connection between my mobile and pc.
can you help me with some guide..
thanks in advance
gsauce
New User
 
Posts: 1
Joined: Wed May 02, 2012 3:13 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 2 guests

more stuff