| Author |
how to resolve java.net.BindException
|
Binesh Veetil
Greenhorn
Joined: Jan 21, 2012
Posts: 9
|
|
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.
|
 |
Philip Thamaravelil
Ranch Hand
Joined: Feb 09, 2006
Posts: 92
|
|
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
Joined: Jan 21, 2012
Posts: 9
|
|
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
Joined: Feb 09, 2006
Posts: 92
|
|
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:
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
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.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Binesh Veetil
Greenhorn
Joined: Jan 21, 2012
Posts: 9
|
|
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
Joined: Feb 09, 2006
Posts: 92
|
|
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
Joined: Oct 27, 2005
Posts: 19216
|
|
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.
|
 |
 |
|
|
subject: how to resolve java.net.BindException
|
|
|