Results 1 to 15 of 15
Thread: How to handle socket Exception
- 01-08-2008, 06:14 AM #1
Member
- Join Date
- Jan 2008
- Posts
- 8
- Rep Power
- 0
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);
}
}
}
- 01-08-2008, 06:40 AM #2
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.
- 01-08-2008, 10:02 AM #3
Member
- Join Date
- Jan 2008
- Posts
- 8
- Rep Power
- 0
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
- 01-08-2008, 10:10 AM #4
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.
- 01-08-2008, 10:14 AM #5
I tried in my Vista .. showed firewall warning and application ran without problem ..
dont worry newbie, we got you covered.
- 01-08-2008, 01:36 PM #6
Member
- Join Date
- Jan 2008
- Posts
- 8
- Rep Power
- 0
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.
- 01-08-2008, 01:44 PM #7
Member
- Join Date
- Jan 2008
- Posts
- 8
- Rep Power
- 0
- 01-09-2008, 12:12 PM #8
Member
- Join Date
- Jan 2008
- Posts
- 4
- Rep Power
- 0
Make sure port 8080 is not in use...
check it with the netstat command...
- 01-09-2008, 03:04 PM #9
Member
- Join Date
- Jan 2008
- Posts
- 8
- Rep Power
- 0
- 01-09-2008, 03:19 PM #10
Member
- Join Date
- Jan 2008
- Posts
- 4
- Rep Power
- 0
Can you try to make your program listen on another port?
Lets say for example 8889
Does it work then?
- 01-10-2008, 05:58 AM #11
Member
- Join Date
- Jan 2008
- Posts
- 8
- Rep Power
- 0
- 01-10-2008, 09:20 AM #12
Member
- Join Date
- Jan 2008
- Posts
- 8
- Rep Power
- 0
- 01-10-2008, 10:17 AM #13
Member
- Join Date
- Jan 2008
- Posts
- 4
- Rep Power
- 0
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.
- 01-10-2008, 12:53 PM #14
Member
- Join Date
- Jan 2008
- Posts
- 8
- Rep Power
- 0
- 12-21-2010, 11:31 PM #15
Member
- Join Date
- Dec 2010
- Posts
- 1
- Rep Power
- 0
Similar Threads
-
[SOLVED] Handle own exception
By stevemcc in forum New To JavaReplies: 3Last Post: 04-10-2008, 04:55 AM -
Trouble with factory method - unhandled exception type Exception
By desmond5 in forum New To JavaReplies: 1Last Post: 03-08-2008, 06:41 PM -
Better way to handle exceptions
By javaplus in forum Advanced JavaReplies: 2Last Post: 01-16-2008, 06:47 PM -
handle wrong input int/null
By Camden in forum New To JavaReplies: 1Last Post: 12-16-2007, 09:37 PM -
how to handle exceptions
By paty in forum Advanced JavaReplies: 2Last Post: 08-05-2007, 04:17 AM


LinkBack URL
About LinkBacks


Bookmarks