Add variables to errno and socket

- to make sure they work cross platform without having to do
complicated tests
This commit is contained in:
Peter Šurda 2017-05-27 19:00:19 +02:00
parent b37a05fd0a
commit d699a28e49
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -22,6 +22,7 @@ depends.check_dependencies()
import signal # Used to capture a Ctrl-C keypress so that Bitmessage can shutdown gracefully. import signal # Used to capture a Ctrl-C keypress so that Bitmessage can shutdown gracefully.
# The next 3 are used for the API # The next 3 are used for the API
from singleinstance import singleinstance from singleinstance import singleinstance
import errno
import socket import socket
import ctypes import ctypes
from struct import pack from struct import pack
@ -92,7 +93,16 @@ def connectToStream(streamNumber):
a.setup(streamNumber, selfInitiatedConnections) a.setup(streamNumber, selfInitiatedConnections)
a.start() a.start()
def _fixWinsock(): def _fixSocket():
if sys.platform.startswith('linux'):
socket.SO_BINDTODEVICE = 25
if not sys.platform.startswith('win'):
errno.WSAEWOULDBLOCK = errno.EWOULDBLOCK
errno.WSAENETUNREACH = errno.ENETUNREACH
errno.WSAECONNREFUSED = errno.ECONNREFUSED
errno.WSAEHOSTUNREACH = errno.EHOSTUNREACH
if not sys.platform.startswith('win'): if not sys.platform.startswith('win'):
return return
@ -177,7 +187,7 @@ if shared.useVeryEasyProofOfWorkForTesting:
class Main: class Main:
def start(self, daemon=False): def start(self, daemon=False):
_fixWinsock() _fixSocket()
shared.daemon = daemon shared.daemon = daemon