Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | # |
2 | # SPDX-License-Identifier: MIT | ||||
3 | # | ||||
4 | |||||
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 5 | import socket |
6 | |||||
7 | def get_free_port(): | ||||
8 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||||
9 | s.bind(('', 0)) | ||||
10 | addr = s.getsockname() | ||||
11 | s.close() | ||||
12 | return addr[1] |