Mercurial > vim
comparison src/testdir/test_channel.py @ 20003:e373843e2980 v8.2.0557
patch 8.2.0557: no IPv6 support for channels
Commit: https://github.com/vim/vim/commit/bfe13ccc58ccb96f243a58309800410db1ccb52c
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Apr 12 17:53:12 2020 +0200
patch 8.2.0557: no IPv6 support for channels
Problem: No IPv6 support for channels.
Solution: Add IPv6 support. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/5893)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 12 Apr 2020 18:00:07 +0200 |
parents | 33a2277b8d4d |
children | 235be779549f |
comparison
equal
deleted
inserted
replaced
20002:2bf41f30475c | 20003:e373843e2980 |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Server that will accept connections from a Vim channel. | 3 # Server that will accept connections from a Vim channel. |
4 # Used by test_channel.vim. | 4 # Used by test_channel.vim. |
5 # | 5 # |
6 # This requires Python 2.6 or later. | 6 # This requires Python 2.6 or later. |
233 # Write the port number in Xportnr, so that the test knows it. | 233 # Write the port number in Xportnr, so that the test knows it. |
234 f = open("Xportnr", "w") | 234 f = open("Xportnr", "w") |
235 f.write("{0}".format(port)) | 235 f.write("{0}".format(port)) |
236 f.close() | 236 f.close() |
237 | 237 |
238 if __name__ == "__main__": | 238 def main(host, port, server_class=ThreadedTCPServer): |
239 HOST, PORT = "localhost", 0 | |
240 | |
241 # Wait half a second before opening the port to test waittime in ch_open(). | 239 # Wait half a second before opening the port to test waittime in ch_open(). |
242 # We do want to get the port number, get that first. We cannot open the | 240 # We do want to get the port number, get that first. We cannot open the |
243 # socket, guess a port is free. | 241 # socket, guess a port is free. |
244 if len(sys.argv) >= 2 and sys.argv[1] == 'delay': | 242 if len(sys.argv) >= 2 and sys.argv[1] == 'delay': |
245 PORT = 13684 | 243 port = 13684 |
246 writePortInFile(PORT) | 244 writePortInFile(port) |
247 | 245 |
248 print("Wait for it...") | 246 print("Wait for it...") |
249 time.sleep(0.5) | 247 time.sleep(0.5) |
250 | 248 |
251 server = ThreadedTCPServer((HOST, PORT), ThreadedTCPRequestHandler) | 249 server = server_class((host, port), ThreadedTCPRequestHandler) |
252 ip, port = server.server_address | 250 ip, port = server.server_address[0:2] |
253 | 251 |
254 # Start a thread with the server. That thread will then start a new thread | 252 # Start a thread with the server. That thread will then start a new thread |
255 # for each connection. | 253 # for each connection. |
256 server_thread = threading.Thread(target=server.serve_forever) | 254 server_thread = threading.Thread(target=server.serve_forever) |
257 server_thread.start() | 255 server_thread.start() |
261 print("Listening on port {0}".format(port)) | 259 print("Listening on port {0}".format(port)) |
262 | 260 |
263 # Main thread terminates, but the server continues running | 261 # Main thread terminates, but the server continues running |
264 # until server.shutdown() is called. | 262 # until server.shutdown() is called. |
265 try: | 263 try: |
266 while server_thread.isAlive(): | 264 while server_thread.is_alive(): |
267 server_thread.join(1) | 265 server_thread.join(1) |
268 except (KeyboardInterrupt, SystemExit): | 266 except (KeyboardInterrupt, SystemExit): |
269 server.shutdown() | 267 server.shutdown() |
268 | |
269 if __name__ == "__main__": | |
270 main("localhost", 0) |