Unity Client & Server Socket

Hello, I have a shared server that I'm using for hosting. On the server I have a **MySQL database** that I'm storing some **user info** for the current and next session. Currently, I use a login system and communicate the user info through **POST requests to PHP files** that then communicate with the DB. However, I want to transition this into a **client/server socket**. I'm not terribly interested in using third party services and am willing to learn a lot for a great solution.

My question is two parts. Please contribute to either.

First, do you know of any guides or can provide a summary for setting up a c# .net server and then server socket program? Searching online has lead me to regurgitations of Microsoft’s code example which gives no clarification on server configuration/setup. Also, I believe this requires me to move to a dedicated server so I can establish .net framework… is that true?

Second, what other languages or programs could be used to handle the server side socket for the purpose stated above (and works well/easy with unity/c#)?

Thanks in advance! At first, any contribution is appreciated

Edit:

A little more detail about the needs of the client/server connection → the needs are similar to a chat system where clients will send out messages (couple floats and strings) and the server will parse the information then broadcast results based on the parse (couple floats and strings). The server should parse messages in the order received but broadcast results immediately after parsing. As far as CCU’s, I’m interested in limitations. This application can operate adequately with a dozen or millions (gotta dream, right?) of users at a time, so multiple “rooms”/servers would be needed depending on user growth and CCU limits. Latency requirements aren’t extreme because the user is presented info through text so there’s no need for visual synchronization or anything like that.

There’s a complete client / server example on the Unity wiki. It should give you a very rough overview. The particular implementation is actually pretty bad for several reasons. However networking can grow infinite complex depending on your requirements. The required sendrate, the amount of data per message, the number of concurrent users and the required response time are just a few things which can heavily influence how you would implement your networking.

Keep in mind that when you want to roll your own high level network protocol you have to get your hands dirty. There are a lot of things to learn, especially about threading, concurrency, synchronation. But also about proper framing of your messages (which is completely missing from the example). While there are technically many different low level protocols that could be used, the only two usually used are TCP and UDP. Those work fundamentally different. While UDP is an unreliable packet based protocol and limited by the MTU size, TCP is a reliable streaming protocol. You can send messages or packets over TCP, but data might be fragmented on the way. So the reassembly and splitting into seperate messages has to be done by yourself.

You haven’t given much details about what you actually need your client / server connection. So we can’t really go more into detail here. Apart from that all of that isn’t really related to Unity ^^.