diff options
Diffstat (limited to 'meta/lib/oeqa/utils/network.py')
-rw-r--r-- | meta/lib/oeqa/utils/network.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/meta/lib/oeqa/utils/network.py b/meta/lib/oeqa/utils/network.py new file mode 100644 index 0000000000..59d01723a1 --- /dev/null +++ b/meta/lib/oeqa/utils/network.py @@ -0,0 +1,12 @@ +# +# SPDX-License-Identifier: MIT +# + +import socket + +def get_free_port(udp = False): + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM if not udp else socket.SOCK_DGRAM) + s.bind(('', 0)) + addr = s.getsockname() + s.close() + return addr[1] |