Commits

Roger Light committed 32c953e

Use symbolic errno values rather than numbers in Python module to avoid
cross platform issues (incorrect errno on Mac OS). Thanks to codehugger.

Comments (0)

Files changed (2)

   client connects without a certificate.
 - mosquitto_passwd should only be installed if WITH_TLS=yes.
 
+Library:
+- Use symbolic errno values rather than numbers in Python module to avoid
+  cross platform issues (incorrect errno on Mac OS).
+
 Other:
 - Build script fixes for FreeBSD.
 

lib/python/mosquitto.py

 This is an MQTT v3.1 client module. MQTT is a lightweight pub/sub messaging
 protocol that is easy to implement and suitable for low powered devices.
 """
+import errno
 import random
 import select
 import socket
             self.socket().connect((self._host, self._port))
         except socket.error as err:
             (msg) = err
-            if msg.errno != 115:
+            if msg.errno != errno.EINPROGRESS:
                 print(msg)
                 return 1
 
                 (msg) = err
                 if self._ssl and (msg.errno == ssl.SSL_ERROR_WANT_READ or msg.errno == ssl.SSL_ERROR_WANT_WRITE):
                     return MOSQ_ERR_AGAIN
-                if msg.errno == 11:
+                if msg.errno == errno.EAGAIN:
                     return MOSQ_ERR_AGAIN
                 print(msg)
                 return 1
                     (msg) = err
                     if self._ssl and (msg.errno == ssl.SSL_ERROR_WANT_READ or msg.errno == ssl.SSL_ERROR_WANT_WRITE):
                         return MOSQ_ERR_AGAIN
-                    if msg.errno == 11:
+                    if msg.errno == errno.EAGAIN:
                         return MOSQ_ERR_AGAIN
                     print(msg)
                     return 1
                 (msg) = err
                 if self._ssl and (msg.errno == ssl.SSL_ERROR_WANT_READ or msg.errno == ssl.SSL_ERROR_WANT_WRITE):
                     return MOSQ_ERR_AGAIN
-                if msg.errno == 11:
+                if msg.errno == errno.EAGAIN:
                     return MOSQ_ERR_AGAIN
                 print(msg)
                 return 1