-5

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?

Pixark
  • 385
  • 1
  • 4
  • 13
  • Your question isn't very specific. What kind of communication? Persistent connection like in an online game? Or do you need non-persistent connection for occasional connections (i.e. submitting scores etc)? – Tseng Feb 13 '14 at 17:59

3 Answers3

1

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.

peter.petrov
  • 38,363
  • 16
  • 94
  • 159
0

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).

Jorge_B
  • 9,712
  • 2
  • 17
  • 22
0

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.

PicoCreator
  • 9,886
  • 7
  • 43
  • 64