aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Address already used problem in Java Socket application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Address already used problem in Java Socket application" Watch "Address already used problem in Java Socket application" New topic
Author

Address already used problem in Java Socket application

Ammy Singh
Ranch Hand

Joined: Oct 17, 2008
Posts: 36
I have made a small server which accepts a client request. The code is as following.
But i am getting an error message as: Exception in thread "main" java.lang.NullPointerException
at ServerSide.main(ServerSide.java:24)
Not a priveleged Userjava.net.BindException: Address already in use: JVM_Bind



i think the problem is with the port number that i am using, but i tried different port numbers and error still exist, please help,
Regards,
Aman


SCJP1.4
i luv Ranch it always helps...!!!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36599
    
  16
And which line is the Exception thrown from?
Ram Narayan.M
Ranch Hand

Joined: Jul 11, 2010
Posts: 247

Port address is already in use...


SCJP 6 [SCJP - Old is Gold]
Ammy Singh
Ranch Hand

Joined: Oct 17, 2008
Posts: 36
Campbell Ritchie wrote:And which line is the Exception thrown from?

The exception is trown at following:

and



And the console result is as : Not a priveleged Userjava.net.BindException: Address already in use: JVM_Bind
Exception in thread "main" java.lang.NullPointerException
at ServerSide.main(ServerSide.java:22)

Ammy Singh
Ranch Hand

Joined: Oct 17, 2008
Posts: 36
Ram Narayan.M wrote:Port address is already in use...


Ok its fine that the port address is already in use, but how can i find an unused port, and note that i am running the program on a standalone server.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36599
    
  16
Too difficult a question for "beginning Java". Moving thread.
Ammy Singh
Ranch Hand

Joined: Oct 17, 2008
Posts: 36
Campbell Ritchie wrote:Too difficult a question for "beginning Java". Moving thread.


ok thank you next time i will take care about which thread to select.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Address already used problem in Java Socket application
 
Similar Threads
JAVA SOCKET PROGRAMMING
NIO non-blocking newbie
Reading a binary file from a client to server
simple socket programming
reading from TCP socket problem