fake_trx/udp_link.py: set SO_REUSEADDR socket option

Setting this option allows one to reuse existing connections,
for example, by injecting CTRL commands or DATA bursts into
existing connections between fake_trx.py and trxcon.

Change-Id: I0882c76affa9a668a12d10967081054d2b666ed1
This commit is contained in:
Vadim Yanitskiy 2018-02-27 04:57:58 +07:00
parent 23446011af
commit 24e30142aa
1 changed files with 1 additions and 0 deletions

View File

@ -27,6 +27,7 @@ import socket
class UDPLink:
def __init__(self, remote_addr, remote_port, bind_port):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.sock.bind(('0.0.0.0', bind_port))
self.sock.setblocking(0)