tag:blogger.com,1999:blog-8712770457197348465.post5381915688856589624..comments2024-03-17T23:01:26.872-07:00Comments on Javarevisited: How to find IP Address of localhost in Java? Example Tutorialjavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-8712770457197348465.post-41420066150243064622020-03-03T18:10:13.205-08:002020-03-03T18:10:13.205-08:00The above code gives an error as follows:
IPTest.j...The above code gives an error as follows:<br />IPTest.java:14: error: cannot find symbol<br /> InetAddress addr = InetAddress.getLocalHost();<br /> ^<br /> symbol: class InetAddress<br /> location: class IPTest<br />IPTest.java:14: error: cannot find symbol<br /> InetAddress addr = InetAddress.getLocalHost();<br /> ^<br /> symbol: variable Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-22203112495900488372016-05-20T18:27:52.112-07:002016-05-20T18:27:52.112-07:00@Anonymous, you can print the client Socket's ...@Anonymous, you can print the client Socket's InetAddress as shown here. That would you your client's IP address You can also see this <a href="http://javarevisited.blogspot.com/2015/06/how-to-create-http-server-in-java-serversocket-example.html" rel="nofollow">Java program to connect an HTTP server</a> to learn more about client server interaction. javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-38240764299488805102016-05-20T11:58:15.541-07:002016-05-20T11:58:15.541-07:00How to know ip address of the clients connected to...How to know ip address of the clients connected to a server ?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-18588004530628611282012-10-09T06:50:58.738-07:002012-10-09T06:50:58.738-07:00Nice example , could have completed as below
...Nice example , could have completed as below<br /> //Getting IPAddress of localhost - getHostAddress return IP Address<br /> // in textual format<br /> System.out.println("IP address of localhost from Java Program: " + InetAddress.getLocalHost().getHostAddress());<br /> //Hostname<br />System.out.println("Name of hostname : " +Anonymoushttps://www.blogger.com/profile/03039317047510102358noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-48515315520820215852012-09-06T04:58:20.381-07:002012-09-06T04:58:20.381-07:00also, if your computer have more then one IP you c...also, if your computer have more then one IP you can find all of them with these lines of code<br /><br /><br />InetAddress localhost = InetAddress.getLocalHost();<br />List adresses = InetAddress.getAllByName(localhost.getCanonicalHostName())Anonymoushttps://www.blogger.com/profile/17989706185150087780noreply@blogger.com