blob: 59cbbc4f1bccb433ec6db3cace8d7db4c1681797 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
2# SPDX-License-Identifier: MIT
3#
4
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05005import socket
6
7def 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]