Skip to content

Commit

Permalink
Add variables to errno and socket
Browse files Browse the repository at this point in the history
- to make sure they work cross platform without having to do
complicated tests
  • Loading branch information
PeterSurda committed May 27, 2017
1 parent b37a05f commit d699a28
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/bitmessagemain.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import signal # Used to capture a Ctrl-C keypress so that Bitmessage can shutdown gracefully.
# The next 3 are used for the API
from singleinstance import singleinstance
import errno
import socket
import ctypes
from struct import pack
Expand Down Expand Up @@ -92,7 +93,16 @@ def connectToStream(streamNumber):
a.setup(streamNumber, selfInitiatedConnections)
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'):
return

Expand Down Expand Up @@ -177,7 +187,7 @@ def run(self):

class Main:
def start(self, daemon=False):
_fixWinsock()
_fixSocket()

shared.daemon = daemon

Expand Down

0 comments on commit d699a28

Please sign in to comment.