在端口上写这个:- try
- {
- // Enviamos los bytes
- DataOutputStream dOut = null;
- dOut = new DataOutputStream(socket.getOutputStream());
- // Send message
- dOut.writeBytes(res);
- dOut.flush();
- }
- catch (IOException e)
- {
- Dialogs.showErrorDialog("Error al recuperar la fecha y hora del dispositivo Nonin.", this);
- }
复制代码 当响应可以访问的时候从端口上读:- DataInputStream dIn = null;
- // We receive the answer
- try
- {
- dIn = new DataInputStream(socket.getInputStream());
- }
- catch (IOException e)
- {
- Dialogs.showAlertDialog("An exception occured during bluetooth io stream creation", this);
- }
- while (true)
- {
- try
- {
- String data = dIn.readLine(); // readLine();
- byte[] total = EncodingUtils.getBytes(data, "ASCII");
- Dialogs.showInfoDialog("Mensaje ok: " + data.toString(), this);
- }
- catch (IOException e)
- {
- break;
- }
- }
复制代码 |