vty test: nat_msc_test: setsockopt REUSE to avoid TIME_WAIT problems

When running the testBSCreload test in close succession, I get a "Connection
refused" error because the socket is still in TIME_WAIT state. Passing the
SO_REUSEADDR flag allows reusing the addr despite a TIME_WAIT socket.

Change-Id: I941851b062999ab4b962430f7b27c19935993e0a
This commit is contained in:
Neels Hofmeyr 2017-02-28 02:38:43 +01:00 committed by Harald Welte
parent d015cbd65d
commit 534034580c
1 changed files with 1 additions and 0 deletions

View File

@ -1207,6 +1207,7 @@ def data2str(d):
def nat_msc_test(x, ip, port, verbose = False):
msc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
msc.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
msc.settimeout(5)
msc.bind((ip, port))
msc.listen(5)