I am about to develop a server using the Java
language for a game.
The game is written in C#
, and they are going to communicate through sockets
.
The only way I can come up with is using JSON
.
What is the proper way to do this?
I am about to develop a server using the Java
language for a game.
The game is written in C#
, and they are going to communicate through sockets
.
The only way I can come up with is using JSON
.
What is the proper way to do this?
The proper way is to have either a RESTful or a SOAP-based web service on the server
side and the client to call it. This is also going through sockets on the lowest level.
If you want, you can implement socket-based communication yourself (no REST/SOAP)
but I would not recommend it as it will make your job more difficult and error-prone.
But on the other hand, this may be more efficient, if you implement it well.
So you have many options, it all depends on the exact needs/requirements.
If you want to communicate properly your applications, I suggest you think about a multi-threaded server, in which every worker thread should poll the open socket and deal with the request, and you should write all this with kind of low-level I/O and multi-threading APIs.
Though it is possible to do it, I must recommend you to leave your communications to an application server, for example a Tomcat server or something similar. There you can deploy your java server as a web application implementing a REST or SOAP based webservice.
This way, you are covered with a production-strength server doing your communications duty for you, and can focus on writing a standard webservice client in C# (I admit I can be of little or no help at all in C#, but I guess someone here will be glad to help you there).
If your looking for a convenient API / library to communicate between apps, you may want to consider zeroMQ.
For webserver-client models. You may want to consider implementing a HTTP REST/SOAP interface.