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