Check for internet connection in Macruby
Checking for internet connectivity in a Macruby app is dead simple.
class MyConnection
require 'socket'
def has_connection?
!Socket.getaddrinfo('google.com', nil).empty?
rescue
false
end
end
Written by Jay Fajardo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#