Gitiles
Code Review
Sign In
gerrit.openbmc.org
/
mdmillerii
/
openbmc
/
95ac1b8d7409c14ee15ddcb7e5dd3d28b24caa7f
/
.
/
poky
/
meta
/
lib
/
oeqa
/
utils
/
network.py
blob: 59d01723a1ebef9ede5c82a54b3f539408e15f76 [
file
] [
log
] [
blame
]
#
# 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
]