Opening ServerSocket
Dear All,
I am trying to instantiate a ServerSocket on a server with the following code:
serverSocket= new ServerSocket(PORTNUM);
But I get the following exception error message on that server:
java.security.AccessControlException: access denied (java.net.SocketPermission localhost:1234 listen,resolve)
I know that on the client side it is necessary to either grant permission for socket comunication in a policy file or sign the jar file. But what do I need to do extra on the server? Where to put a policy file?
Unfortunately, the hosting server is not fully under my control. I use a hosting service. So I may not have the server access required to change certain settings...
Thanks for your help,
Merlijn
Hello Brightokona,
I am not sure why you posted your post as a reply to my question, but I can explain how I deploy servlets:
1) Your hosting service must allow/enable JSP's and Java Servlets.
2) After writing the servlet, compile them. (You will need JSDK for that.)
3) In the web page root directory you will find the WEB-INF/classes dir.
4) FTP your servlet .class files to the WEB-INF/classes dir.
5) Call servlet by www.yourpages.com/servlet/xxxx (xxxx is the servlet name without the .class extension.)
Hope this helps, and that the way you deploy servlets with your hosting service is not very different. But the helpdesk can explain you the details for your case.
Merlijn
Hello Sjasja and Peter,
I checked with my hosting service. Indeed, they do not allow opening ServerSockets on their servers. That is very unfortunate.
It is my intention to make a multiplayer game. Users go to a webpage with an applet, and communication between users takes place via the server. HTTP POSTing is too slow, sockets are not allowed on the server... Do you have any suggestions for communication from client <--> server <--> client.
Thanks,
Merlijn