[gnome-keysign: 34/65] bluetooth: add shutdown() before close()



commit 52a8d99e62e8da3a0ab22d6add18d4266bb8674f
Author: RyuzakiKK <aasonykk gmail com>
Date:   Sun Aug 20 19:31:24 2017 +0200

    bluetooth: add shutdown() before close()
    
    In this way we stop the socket in a cleaner manner.

 keysign/bluetoothoffer.py   | 2 ++
 keysign/bluetoothreceive.py | 5 ++---
 2 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/keysign/bluetoothoffer.py b/keysign/bluetoothoffer.py
index ee717e2..94cae44 100644
--- a/keysign/bluetoothoffer.py
+++ b/keysign/bluetoothoffer.py
@@ -2,6 +2,7 @@ import logging
 from bluetooth import BluetoothSocket, RFCOMM
 import dbus
 import select
+import socket
 if __name__ == "__main__":
     import gi
     gi.require_version('Gtk', '3.0')
@@ -92,6 +93,7 @@ class BluetoothOffer:
         log.debug("Stopping bt receive")
         self.stopped = True
         if self.server_socket:
+            self.server_socket.shutdown(socket.SHUT_RDWR)
             self.server_socket.close()
             self.server_socket = None
 
diff --git a/keysign/bluetoothreceive.py b/keysign/bluetoothreceive.py
index d0af651..e5483f8 100644
--- a/keysign/bluetoothreceive.py
+++ b/keysign/bluetoothreceive.py
@@ -1,6 +1,7 @@
 import logging
 import select
 from bluetooth import BluetoothSocket, BluetoothError, RFCOMM
+import socket
 
 if __name__ == "__main__":
     import gi
@@ -97,9 +98,7 @@ class BluetoothReceive:
     def stop(self):
         self.stopped = True
         if self.client_socket:
-            # Seems that is useless :/
-            #import socket
-            #self.client_socket.shutdown(socket.SHUT_RDWR)
+            self.client_socket.shutdown(socket.SHUT_RDWR)
             self.client_socket.close()
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]