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)
|
||||
else:
|
||||
newSocket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP)
|
||||
socket.connect($dest, 80.Port)
|
||||
result = socket.getLocalAddr()[0].parseIpAddress()
|
||||
socket.close()
|
||||
try:
|
||||
socket.connect($dest, 80.Port)
|
||||
result = socket.getLocalAddr()[0].parseIpAddress()
|
||||
finally:
|
||||
socket.close()
|
||||
|
|
Loading…
Reference in New Issue