close socket if exception occurs too
This commit is contained in:
parent
fc9219ed80
commit
492e5ee72f
|
@ -23,6 +23,8 @@ proc getPrimaryIPAddr*(dest = parseIpAddress("8.8.8.8")): IpAddress =
|
||||||
newSocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)
|
newSocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)
|
||||||
else:
|
else:
|
||||||
newSocket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP)
|
newSocket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP)
|
||||||
socket.connect($dest, 80.Port)
|
try:
|
||||||
result = socket.getLocalAddr()[0].parseIpAddress()
|
socket.connect($dest, 80.Port)
|
||||||
socket.close()
|
result = socket.getLocalAddr()[0].parseIpAddress()
|
||||||
|
finally:
|
||||||
|
socket.close()
|
||||||
|
|
Loading…
Reference in New Issue