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

[765 byte] By [merlijnjanssena] at [2007-10-2 21:39:15]
# 1
Does the hosting service disallow server socket creation on purpose? If they disallow it you are not supposed to hack around it...
sjasjaa at 2007-7-14 0:53:49 > top of Java-index,Archived Forums,Socket Programming...
# 2
The operation is probibly blocked by the SecurityManager
Peter__Lawreya at 2007-7-14 0:53:49 > top of Java-index,Archived Forums,Socket Programming...
# 3
Hi all, does any one know how I can deploy my servlet on a hosted server. I dont have the capability of hosting my serverlet so that clients can connect over the internet. Please I want to know how i can deploy the servelet on a hosted server.
brightokonaa at 2007-7-14 0:53:49 > top of Java-index,Archived Forums,Socket Programming...
# 4

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

merlijnjanssena at 2007-7-14 0:53:49 > top of Java-index,Archived Forums,Socket Programming...
# 5

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

merlijnjanssena at 2007-7-14 0:53:49 > top of Java-index,Archived Forums,Socket Programming...