{"id":3456,"date":"2016-03-17T00:51:03","date_gmt":"2016-03-17T00:51:03","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=3456"},"modified":"2016-03-17T00:51:03","modified_gmt":"2016-03-17T00:51:03","slug":"get-current-ip-addresses-scala","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/get-current-ip-addresses-scala\/","title":{"rendered":"Get current IP addresses in Scala"},"content":{"rendered":"<p>The following example will print out all of the IP addresses your machine has (i.e. IPv4\/IPv6 and for each network adapter)<\/p>\n<pre lang=\"scala\">\nval e = NetworkInterface.getNetworkInterfaces\nwhile(e.hasMoreElements)\n{\n  val n = e.nextElement match {\n    case e: NetworkInterface => e\n    case _ => ???\n  }\n  val ee = n.getInetAddresses\n  while (ee.hasMoreElements) {\n    ee.nextElement match {\n      case e: InetAddress => println(e.getHostAddress)\n      case _ => ???\n    }\n  }\n}\n<\/pre>\n<p>Here is an example output:<\/p>\n<pre>\nfe80:0:0:0:1240:f3ff:feaf:6848%en1\n192.168.1.2\nfe80:0:0:0:0:0:0:1%lo0\n0:0:0:0:0:0:0:1\n127.0.0.1\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The following example will print out all of the IP addresses your machine has (i.e. IPv4\/IPv6 and for each network adapter) val e = NetworkInterface.getNetworkInterfaces while(e.hasMoreElements) { val n = e.nextElement match { case e: NetworkInterface => e case _ => ??? } val ee = n.getInetAddresses while (ee.hasMoreElements) { ee.nextElement match { case e: &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.garysieling.com\/blog\/get-current-ip-addresses-scala\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Get current IP addresses in Scala&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[381,480,485],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3456"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=3456"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3456\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=3456"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=3456"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=3456"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}