无法连接[10048]

时间:2012-08-12 21:57:33

标签: bluetooth winsock bluecove

我在按钮上有这个代码,当我按下它时我得到错误:

  Error: Exception connecting to NXT.
  Caused by lejos.pc.comm.NXTCommException: Open of NXT failed.
at lejos.pc.comm.NXTCommBluecove.open(NXTCommBluecove.java:136)
   Caused by javax.bluetooth.BluetoothConnectionException: Failed to connect; [10048]
 Only one usage of each socket address (protocol/network address/port) is normally permitted.
at com.intel.bluetooth.BluetoothStackMicrosoft.connect(Native Method)
Failed to connect to any NXT

我发帖是因为昨天工作正常但似乎今天没有工作。

btnConnectBot.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (Cnt1){
                try {
                    conn.close();
                    Cnt1=!Cnt1;
                    txtConnState.setText("Off");
                    txtConnState.setForeground(Color.RED);
                } catch (IOException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
            }
            else{   
                conn.addLogListener(new NXTCommLogListener() {
                public void logEvent(String message) {
                System.out.println(message);
                }

                public void logEvent(Throwable throwable) {
                System.err.println(throwable.getMessage());
                }
                });
                conn.setDebug(true);
                if (!conn.connectTo(txtBotName.getText(), NXTComm.LCP)) {
                System.err.println("Fallo de conexión");
                txtConnState.setText("Off");
                txtConnState.setForeground(Color.RED);
                System.exit(1);
                }
                Cnt1=!Cnt1;     
                txtConnState.setText("On");
                txtConnState.setForeground(Color.GREEN);

                if (chckbxLock_2.isSelected()){
                    btnConnectBot_2.doClick();
                }
                if (chckbxLock_1.isSelected()){
                    btnConnectBot_1.doClick();
                }
            }
        }
    });

根据我的研究,这是因为正在使用的蓝牙端口正由多个实例访问。但我不知道在这段代码中会发生这种情况。

1 个答案:

答案 0 :(得分:0)

您是否为远程设备配置了蓝牙虚拟COM端口?也许它是由一些程序打开的......

或者,第一次运行程序时是否出现错误?是否有任何旧程序的副本正在运行 - 请检入taskmgr.exe