• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to resolve java.net.BindException

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to create a new ServerSocket object and I am getting the following error:
java.net.BindException: Cannot assign requested address: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(Unknown Source)

Code to create server socket is as follows:
server = new ServerSocket(port, 0, hostInetAddress);

Please help me resolve this.
 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Binesh Veetil wrote:I am trying to create a new ServerSocket object and I am getting the following error:
java.net.BindException: Cannot assign requested address: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(Unknown Source)

Code to create server socket is as follows:
server = new ServerSocket(port, 0, hostInetAddress);

Please help me resolve this.




The issue is simple. A process is already bound to the port in questions. Are you on a linux box or a window box?

Cheers,
Philip
 
Binesh Veetil
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Philip Thamaravelil wrote:

The issue is simple. A process is already bound to the port in questions. Are you on a linux box or a window box?

Cheers,
Philip



I am on linux box.
 
Philip Thamaravelil
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Binesh Veetil wrote:

Philip Thamaravelil wrote:

The issue is simple. A process is already bound to the port in questions. Are you on a linux box or a window box?

Cheers,
Philip



I am on linux box.





so, to determine what process id is running on your port, run:

 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Philip Thamaravelil wrote:The issue is simple. A process is already bound to the port in questions.


Not necessarily. On Linux and Unix regular users cannot open ports below 1024. You need root access for that.
 
Binesh Veetil
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Not necessarily. On Linux and Unix regular users cannot open ports below 1024. You need root access for that.


What do you mean by root access? Will I be able to do a telnet from IP to another like : <telnet IP Port> port numbers which I am using are below 1024 as well.
 
Philip Thamaravelil
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Binesh Veetil wrote:

Rob Spoor wrote:Not necessarily. On Linux and Unix regular users cannot open ports below 1024. You need root access for that.


What do you mean by root access? Will I be able to do a telnet from IP to another like : <telnet IP Port> port numbers which I am using are below 1024 as well.




telenet'ing to another machine is completely unrelated to your ability to bind a process to a port on the local machine.

In your post, you mentioned your trying to start an application that will bind and listen on port XXXX. Rob makes a great point, that you either need to select a port number > 1024 OR you must run the process as the user root. IMO, your better off selecting a higher numbered port as your less likely to run into port conflicts with another process.

Cheers,
Philip
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Binesh Veetil wrote:

Rob Spoor wrote:Not necessarily. On Linux and Unix regular users cannot open ports below 1024. You need root access for that.


What do you mean by root access? Will I be able to do a telnet from IP to another like : <telnet IP Port> port numbers which I am using are below 1024 as well.


Connecting to a port with a client is allowed for any user. Otherwise you couldn't even browse the web. The 1024 limitation only exists for listening to incoming connections.
 
Weeds: because mother nature refuses to be your personal bitch. But this tiny ad is willing:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic