Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-08-2008, 07:14 AM
Member
 
Join Date: Jan 2008
Posts: 8
mayank0512 is on a distinguished road
How to handle socket Exception
Sir i am running this code on windows vista, but i am getting the Socket Exception: Permission Denied:: Listen failed.I am trying to run this application on port 8080.On this very port i am running tomcat6.0,so even when i changed the port same exception arises.
Similar Exceptions were there when i run tomcat6.0 but when i installed tomcat6.0 as a service it worked fine.
So, please sir what should i do run this code on my machine.
I have Java SE(TM)Run Time Environment6 running, also mcafee antivirus running.Please post me a solution if possible
import java.io.IOException;
import java.net.*;

public class SocketTest
{

/**
* @param args
*/
public static void main(String[] args)
{

ServerSocket myService;

try
{
myService = new ServerSocket(8080);
System.out.println("successfully opened a socket");

}
catch (IOException e)
{
e.printStackTrace();
System.out.println(e);
}


}

}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-08-2008, 07:40 AM
roots's Avatar
Moderator
 
Join Date: Jan 2008
Location: Dallas
Posts: 251
roots is on a distinguished road
Either mcafee or windows firewall .. if 8080 is already used it will throw BindException .. You can catch that as well before IOException.
Paste StackTrace so that we can be sure on this ..

happy socketing ..
__________________
dont worry newbie, we got you covered.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-08-2008, 11:02 AM
Member
 
Join Date: Jan 2008
Posts: 8
mayank0512 is on a distinguished road
Socket Exception
The StackTrace is::
java.net.SocketException: Permission denied: listen failed
at java.net.PlainSocketImpl.socketListen<Native Method>
at java.net.PlainSocketImpl.listen<Unknown Source>
at java.net.SeverSocket.bind<Unknown Source>
at java.net.SeverSocket.<init><Unknown Source>
at java.net.SeverSocket.<init><Unknown Source>
at SocketTest.main<socketTest.java:17>
java.net.SocketException:Permission denied: listen failed
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-08-2008, 11:10 AM
roots's Avatar
Moderator
 
Join Date: Jan 2008
Location: Dallas
Posts: 251
roots is on a distinguished road
May be you dont have permission to open that port. Try run as Administrator .. If you are using cmd line .. type cmd in Start menu search bar and run cmd as administrator from there..

Let me know ..
__________________
dont worry newbie, we got you covered.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 01-08-2008, 11:14 AM
roots's Avatar
Moderator
 
Join Date: Jan 2008
Location: Dallas
Posts: 251
roots is on a distinguished road
I tried in my Vista .. showed firewall warning and application ran without problem ..
__________________
dont worry newbie, we got you covered.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 01-08-2008, 02:36 PM
Member
 
Join Date: Jan 2008
Posts: 8
mayank0512 is on a distinguished road
Quote:
Originally Posted by roots View Post
I tried in my Vista .. showed firewall warning and application ran without problem ..
Same Exception even when i ran cmd-prompt as an administartor.
One more thing is that i have my windows firewall settings turned off, should i make any changes in that i.e make it on.
What should i do ?? Do tell me i am fet up of this exception. Is there a problem with the O.S.
Similar problems as i told u were there with the tomcat6.0. But with some discussion when i installed tomcat as a service and ran as an administartor, problem vanished totally.
But here no such result as yet.I don't think that there is a problem with the code that i posted.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 01-08-2008, 02:44 PM
Member
 
Join Date: Jan 2008
Posts: 8
mayank0512 is on a distinguished road
Quote:
Originally Posted by roots View Post
I tried in my Vista .. showed firewall warning and application ran without problem ..
Now even i have changed the firewall settings.
Still the result is the same.........
Help me out............
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 01-09-2008, 01:12 PM
Member
 
Join Date: Jan 2008
Posts: 4
FredJavaFreak is on a distinguished road
Make sure port 8080 is not in use...

check it with the netstat command...
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 01-09-2008, 04:04 PM
Member
 
Join Date: Jan 2008
Posts: 8
mayank0512 is on a distinguished road
Quote:
Originally Posted by FredJavaFreak View Post
Make sure port 8080 is not in use...

check it with the netstat command...
Yes i have checked the port , it's free.
Is there any issue with the firewall settings, or with the mcafee settings. Do tell me , so that i could make necessary changes.
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 01-09-2008, 04:19 PM
Member
 
Join Date: Jan 2008
Posts: 4
FredJavaFreak is on a distinguished road
Can you try to make your program listen on another port?

Lets say for example 8889

Does it work then?
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 01-10-2008, 06:58 AM
Member
 
Join Date: Jan 2008
Posts: 8
mayank0512 is on a distinguished road
Quote:
Originally Posted by FredJavaFreak View Post
Can you try to make your program listen on another port?

Lets say for example 8889

Does it work then?
Yes i have changed the port , but it's not running . The result is the same.
now what should i do???
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 01-10-2008, 10:20 AM
Member
 
Join Date: Jan 2008
Posts: 8
mayank0512 is on a distinguished road
Quote:
Originally Posted by roots View Post
I tried in my Vista .. showed firewall warning and application ran without problem ..
I ran cmd-prompt as an administrator but it still shows the same exceptions.
what should i do????
Bookmark Post in Technorati
Reply With Quote
  #13 (permalink)  
Old 01-10-2008, 11:17 AM
Member
 
Join Date: Jan 2008
Posts: 4
Sreejesh is on a distinguished road
Might be the prolem with the IDE
If you are using eclipse IDE or a similar one exit from the IDE and try running the code again.
Bookmark Post in Technorati
Reply With Quote
  #14 (permalink)  
Old 01-10-2008, 01:53 PM
Member
 
Join Date: Jan 2008
Posts: 8
mayank0512 is on a distinguished road
Quote:
Originally Posted by Sreejesh View Post
If you are using eclipse IDE or a similar one exit from the IDE and try running the code again.
No i am not using eclipse. I sit an issue related with the mcafee antivirus settings.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Handle own exception stevemcc New To Java 3 04-10-2008 05:55 AM
Trouble with factory method - unhandled exception type Exception desmond5 New To Java 1 03-08-2008 07:41 PM
Better way to handle exceptions javaplus Advanced Java 2 01-16-2008 07:47 PM
handle wrong input int/null Camden New To Java 1 12-16-2007 10:37 PM
how to handle exceptions paty Advanced Java 2 08-05-2007 05:17 AM


All times are GMT +3. The time now is 03:35 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org