45 self.__connection = None |
45 self.__connection = None |
46 |
46 |
47 # setup the network interface |
47 # setup the network interface |
48 if ip is None: |
48 if ip is None: |
49 networkInterface = Preferences.getDebugger("NetworkInterface") |
49 networkInterface = Preferences.getDebugger("NetworkInterface") |
50 if networkInterface == "all" or "." in networkInterface: |
50 if networkInterface in ("allv4", "localv4") or "." in networkInterface: |
51 # IPv4 |
51 # IPv4 |
52 self.__hostAddress = "127.0.0.1" |
52 self.__hostAddress = "127.0.0.1" |
53 else: |
53 elif networkInterface in ("all", "allv6", "localv6"): |
54 # IPv6 |
54 # IPv6 |
55 self.__hostAddress = "::1" |
55 self.__hostAddress = "::1" |
|
56 else: |
|
57 self.__hostAddress = networkInterface |
56 else: |
58 else: |
57 self.__hostAddress = ip |
59 self.__hostAddress = ip |
58 self.listen(QHostAddress(self.__hostAddress)) |
60 self.listen(QHostAddress(self.__hostAddress)) |
59 |
61 |
60 self.newConnection.connect(self.handleNewConnection) |
62 self.newConnection.connect(self.handleNewConnection) |
61 |
63 |
62 ## Note: Need the port if writer is started external in debugger. |
64 ## Note: Need the address and port if client is started external in debugger. |
|
65 hostAddressStr = ( |
|
66 "[{0}]".format(self.__hostAddress) |
|
67 if ":" in self.__hostAddress |
|
68 else self.__hostAddress |
|
69 ) |
63 print( # __IGNORE_WARNING_M801__ |
70 print( # __IGNORE_WARNING_M801__ |
64 "JSON reader ({1}) listening on: {0:d}".format( |
71 "JSON server ({2}) listening on: {0}:{1:d}".format( |
65 self.serverPort(), self.__name |
72 hostAddressStr, self.serverPort(), self.__name |
66 ) |
73 ) |
67 ) |
74 ) |
68 |
75 |
69 def address(self): |
76 def address(self): |
70 """ |
77 """ |