Catch an exception thrown if no default route exists
git-svn-id: file:///home/svn/incoming/trunk@3480 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
7ee4d05bec
commit
f4c07e8a54
|
@ -146,10 +146,14 @@ module Socket
|
|||
##
|
||||
|
||||
def self.source_address(dest='1.2.3.4')
|
||||
self.create_udp(
|
||||
'PeerHost' => dest,
|
||||
'PeerPort' => 31337
|
||||
).getsockname[1]
|
||||
begin
|
||||
return self.create_udp(
|
||||
'PeerHost' => dest,
|
||||
'PeerPort' => 31337
|
||||
).getsockname[1]
|
||||
rescue ::Exception
|
||||
return '127.0.0.1'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue