i'm developing online multiplayer game in java. It will be an executable jar file. Its a single server multi client application. where the server should be able to broadcast, multicast and uni cast to the clients.what will be the best solution to implement the same. keeping security into consideration is socket the best solution?
Asked
Active
Viewed 827 times
0
-
If the multiplayer aspect is over a network, then ultimately there are sockets involved somewhere. – Some programmer dude Nov 10 '12 at 07:11
-
2What alternatives to sockets are you considering? – Greg Hewgill Nov 10 '12 at 07:20
-
@GregHewgill..right now i know only about sockets.Is there any other alternative that you are aware of? – nikhil Nov 10 '12 at 08:09
2 Answers
0
If it's a game that is going on in realtime, then yes.
Alternatively, you could use JSON requests or similar to a webserver for less time critical data. Some games (such as some turnbased ones) base the client/server communication entirely on JSON requests.
A combination of the two is ofcourse possible, and might help shift some load away from your main server application.
For non-realtime stuff, i'm personally a big fan of running a lightweight webserver on some non-standard port (anything above 1024) dedicated to non-web stuff, such as games or other clientside applications pulling stuff out of CGI scripts via GET/POST requests. It's ugly, but it works fine, and it saves me a lot of hassle. The user doesn't really notice a difference.

Jarmund
- 3,003
- 4
- 22
- 45
-
but JSON works on request/response right?but our game will not be restricted to req/res.server should be able to communicate with the clients anytime. – nikhil Nov 10 '12 at 08:22
-
@user1814087 In that case, you will need a form of socket, or perhaps an already existing class that wraps around a socket. JSON requests can be used in addition to pull data that isn't time critical, hence why it can be used in combination with a socket. I used it for updating global hischores and chat. – Jarmund Nov 10 '12 at 08:55
-
what do you feel of the security issues?? cox i am expecting atleast 100s of sockets running at a time. – nikhil Nov 10 '12 at 09:15
-
@user1814087 Over the socket i use public/private keys for encryption, in addition to initial authentication. Always assume that someone is reading the contents of the network traffic. The JSON part is encrypted with the same keys that are used on the socket. – Jarmund Nov 10 '12 at 09:40