general java server/client tutorial

こ雲淡風輕ζ 提交于 2019-12-22 10:25:47

问题


im developing a multi-player card game that needs the clients to communicate with each other or a general server. i have never done this before so i need some direction or tutorial on how to achieve this.

so far i have created the local, single person version of the game...


回答1:


Sun has a good tutorial on writing a client/server pair complete with code examples.




回答2:


So far i have created the local, single person version of the game...

Great, I would suggest to continue with the local multi-player version of the game ( even when it is controlled by the same "terminal" )

From there you may explore RMI to invoke the methods remotely. It should be much more simpler than creating the multi-player version and add networking.

What RMI does is to abstract the network connectivity and allow you to simplify the execution of remote objects call ( that is, it simplifies having to write your own protocol with sockets )




回答3:


RMI is more complex. You need to understand some concepts before starting with RMI, like extending Remote, RemoteExceptions, etc. And also, running applications powered by RMI require some steps, such as starting rmiregistry, and setting a policies file.

If you are a beginner, start with simple sockets first. They are easier to understand, but somewhat long to code. RMI is easier to code, but somewhat tough to understand.

For Sockets:

TCP Sockets

UDP and Datagrams

For RMI:

Simple tutorial to RMI - Really helped me start



来源:https://stackoverflow.com/questions/2017092/general-java-server-client-tutorial

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!