Hi, I am developing a multi-client/single-server project that communicates through sockets.
The main program listens to a new connection, when a client connects to the server it's handled by a goroutine. On the goroutine I have a switch case based on which services offer to the client based on string massage. Initially, all functions were goroutine but every time the handler should wait that the goroutine is finished cause all services use sockets so I can't have two goroutines running at the same time on the same connection, so I decided to leave just a function.
The main problem is C# because there are many ways to implements socket, I have many forms on my C# application, Initially, I pass a reference of a socket connection through all forms but I didn't like this solution, so I define a static socket class and calls send/receive on all form that needs connection using a mutex to avoid concurrence.
Should I use asynchronous sockets or is even synchronous still ok? Should I use another way to create a socket instead of a static class?
What I have tried:
I have tried goroutine, lock, waitgroup on go side.
On C# I have tried to instantiate the class and static class