In order to make sure that I, as a server-side developer, have everything in control, the first version of the server was written using the System.Net.Sockets.Socket class, like the article from Microsoft describes . Since sockets work (in principle, like all other technologies listed further from Microsoft, except WCF) on Begin / End methods, a small wrapper was written that provided the ability to work with the event-based model. This was the first step, the client and server worked fine.
Since very soon we needed SSL, we had to move to a higher level of the OSI model and rewrite the server side using the System.Net.Sockets.TcpListener class, to which SSL was screwed. These were steps two and two and a half, the client and server worked fine, the client did not even have to be rewritten - packet interception showed that everything was OK, nothing had changed.
Later I wanted a full-fledged HTTPS with all its bells and whistles, for which the server was rewritten again - now using the System.Net.HttpListener class. These are steps three and three and a half, and again everything works well, and again the client does not need to be redone. For the sake of fairness, it should be noted that in addition to the custom mobile client, there was also a test C # client and a bunch of tests - but they had to be rewritten at a cost.
The fourth step came when we began to scale our system in all directions, and our own wrappers became the bottleneck of the project. Then I read about WCF and in one evening (well, almost) I rewrote the entire interaction. On the client side (and in the packets being forwarded), everything remains the same, but the server-side code has been reduced from half a dozen serious classes to just a few lines.
This story has two morals.
- (obviously) Inventing bicycles is bad. If I immediately went to Google and were not afraid to use a new technology for myself, I would be able to reduce server development by about a third.
- (and this is the main thing) The task of implementing the same mechanism using different tools is the best way of learning, allowing you to achieve a deep understanding of the topic. When you just do something a few times, you remember it. But when at the same time you complicate (change) the tools used each time, then the skill is sharpened much better.