Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

InetAddress class

 
Syamsul Hussin
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, I am reading the InetAdress API and I cannot locate the constructor method. how do you construct an object of this class?
 
Syamsul Hussin
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lets say if i know the ip address of the host that i want to connect to, and i want to establish a connection using the code:-

and i know which port number i should connect to and the host is listening to that port, can you explain to me how to create the InetAddress object?
 
Syamsul Hussin
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or is it that i can just simply put the ip address as the first argument. if i know the ip address of the host as 213.542.543.12 then i could just
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Syamsul,
InetAddress doesn't have any public constructors so you have to use one of the static methods to get an instance of InetAddress for example:


or is it that i can just simply put the ip address as the first argument. if i know the ip address of the host as 213.542.543.12 ...

It has to be a String. So you need to put quotes around it like this:

Michael Morris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic