1138 @param remoteAddress the network address of the debug server host |
1138 @param remoteAddress the network address of the debug server host |
1139 (string) |
1139 (string) |
1140 @param redirect flag indicating redirection of stdin, stdout and |
1140 @param redirect flag indicating redirection of stdin, stdout and |
1141 stderr (boolean) |
1141 stderr (boolean) |
1142 """ |
1142 """ |
1143 # TODO: replace this by socket.create_connection |
1143 if remoteAddress is None: |
1144 if remoteAddress is None: # default: 127.0.0.1 |
1144 remoteAddress = "127.0.0.1" |
1145 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
1145 sock = socket.create_connection((remoteAddress, port)) |
1146 sock.connect((DebugProtocol.DebugAddress, port)) |
|
1147 else: |
|
1148 if "@@i" in remoteAddress: |
|
1149 remoteAddress, index = remoteAddress.split("@@i") |
|
1150 else: |
|
1151 index = 0 |
|
1152 if ":" in remoteAddress: # IPv6 |
|
1153 sockaddr = socket.getaddrinfo( |
|
1154 remoteAddress, port, 0, 0, socket.SOL_TCP)[0][-1] |
|
1155 sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) |
|
1156 sockaddr = sockaddr[:-1] + (int(index),) |
|
1157 sock.connect(sockaddr) |
|
1158 else: # IPv4 |
|
1159 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
|
1160 sock.connect((remoteAddress, port)) |
|
1161 |
1146 |
1162 self.readstream = AsyncFile(sock, sys.stdin.mode, sys.stdin.name) |
1147 self.readstream = AsyncFile(sock, sys.stdin.mode, sys.stdin.name) |
1163 self.writestream = AsyncFile(sock, sys.stdout.mode, sys.stdout.name) |
1148 self.writestream = AsyncFile(sock, sys.stdout.mode, sys.stdout.name) |
1164 self.errorstream = AsyncFile(sock, sys.stderr.mode, sys.stderr.name) |
1149 self.errorstream = AsyncFile(sock, sys.stderr.mode, sys.stderr.name) |
1165 |
1150 |