• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Simple Socket IP Address Question

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey All -


What is the correct way to find a ServerSocket's IP address? I've tried:
1) getInetAddress() - returns 0.0.0.0/0.0.0.0
1) getLocalSocketAddress() - returns 0.0.0.0/0.0.0.0:4998

The socket is definitely bound, and working locally.


Thanks in advance.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The IP address is associated with a network adapter, not a particular instance of ServerSocket. You can use ifconfig to find those addresses (ipconfig on non-Unix systems).
 
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You mean the serversocket of the machine you are currently in ??? Try :

java.net.InetAddress.getLocalHost().getHostAddress()

Dawn
 
Alex Birmingham
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That did it, Dawn. Thanks!
 
reply
    Bookmark Topic Watch Topic
  • New Topic