I'm making Checkers game in unity for android platform. I was given a task to make this game multiplayer and implement TCP/IP network in C# language, and for Server side I have to use Golang. I nearly finished the game itself, but I don't know nothing about server and tcp, how to implement them for my game. is there any way to start that or tutorials to show how to do that ? Any advice will be great ! Thanks in advance!
-
3This is too broad - SO is for answering specific questions about specific problems, not general advice. There are plenty of tutorials online. – hnefatl Nov 21 '17 at 09:00
-
Your keyword should be `MMORPG`, I have write a simple MMORPG server base on `websocket` write by `Redis + Tornado`. But you should know some basic of `Python`. Here is the rep `https://github.com/land-pack/aking` – Frank AK Nov 21 '17 at 09:05
-
This is assignment, Server should be written in Golang, and TCP/IP network in C#. I have made game in unity, need to know how to implement network stuff? – Sherzodkh Nov 21 '17 at 12:57
1 Answers
Okay, so, you're trying to build the server-client communication of your app. When we talk about communication, there is a keyword that always appear: socket. In short, sockets allow communication between two different processes on the same or different machines. There are different types of sockets, you can check differences between some of them here and here.
To establish a communication channel, the steps that are needed on the client side are:
- Create socket through socket() system call.
- Connect the socket to the server address using connect() system call.
- Send and receive data through read() and write().
And on the server side are:
- Create socket through socket() system call.
- Bind the socket to an address (e.g. ip:port) using the bind() system call.
- Listen for connections with listen() system call.
- Accept a connection with accept() system call.
- Send and receive data through read() and write().
Normally, on the server side you want to create a socket pool, in order to achieve more performance (instead of creating a new socket for each player that connects to your server).
Check the image below to see how is the interaction flow between server and client. In your case, requests are messages sent from players to the server with game info (e.g., the move a player did in its turn). Messages that go from server to the players can be just an ACK or they can be a more elaborated information (e.g., the move an opponent did in its turn).
Now, the transmission of data: Since Internet just can handle bits and does not understand what an object or a struct are, we have to Serialize and Deserialize the messages when they go out to the Internet or arrive from it. To achieve this in an easy you can use Protocol Buffers, a tool built by Uncle Google that simplifies this process and that can be used by different languages (e.g., Go and C#).
Take some examples below on how to build a server-client app in Go and C#, separately. You can then choose which parts do you need to your project:
Hope it helped!

- 417
- 3
- 13