K
K
kos_dev2016-10-23 04:16:38
Programming
kos_dev, 2016-10-23 04:16:38

How to write a server client in C#?

Tell me where you can learn about how to write your server-client technology, that is, both the server and the client itself. What are the best protocols to interact with? What and approximately how to use to write a messenger for two or more remote clients from the server?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
V
VoidVolker, 2016-10-23
@kos_dev

  1. Design the architecture of the system and each application separately;
    The server works as follows (approximately, the details depend on the specifics of the architecture and so on):
    The client works like this:
    1. Looking for a server
    2. Connects to a port;
    3. Passes authentication and authorization;
    4. Waits for data from the server / sends data to the server.

R
Rou1997, 2016-10-23
@Rou1997

System.Net.Sockets (your protocol will be based on TCP) or libraries for WebSocket (your protocol will be based on Websocket, which is based on TCP), the libraries are open source.
At first glance, it’s simple, but if you need to keep the connection open for a long time, then you need to ensure keep-alive, and if you also correctly handle Internet connection failures, then you still have to implement repeated connection attempts and reading data in parts (into the byte[] buffer) , to test internet problems, use programs like NetLimiter and write test code that automatically disconnects the current network when a packet has already started to be sent, or has not yet begun.
But it's not so difficult, just apply multithreading: create a thread for accepting clients, and also a separate thread for working with each client.

M
MrDywar Pichugin, 2016-10-23
@Dywar

1) WCF
2) OWIN Self Host
Everything is ready to use.
There is no need to work with TCP directly, the wrappers are built into .NET.

I
Igor Tkhorik, 2016-10-23
@habcerga1

For me, too, an interesting question that was asked by kos_dev. Perhaps there is some kind of book similar to GOF patterns that describes different technologies and architectures of client-server applications?

L
LiptonOlolo, 2016-10-24
@LiptonOlolo

Write to VK: https://vk.com/dev_0x00
I have more than enough experience in writing group messengers: D

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question