Should I use WCF to implement this binary network protocol?

I have a client device (POS handheld) that communicates via TCP / IP or RS232 with the server. The protocol is a given binary format that I cannot change. I have to implement a server for this device. My impression is that WCF would be a better choice than manually implementing something. But since it will take some time, I would like to ask for advice if this is a good idea, and if you can fine-tune WCF to this level of detail.

I found some questions similar to mine, but in those cases the OP always had full control of the client and server. This does not apply to my scenario.

If WCF is a good idea, I guess some starting points would be much appreciated. Most of the documentation focuses on SOAP, REST, ... and not at the lower levels that I would have to work on.

+6
source share
2 answers

Having worked with WCF for many years (and I like it), I do not think that this is the best option for your needs. As Phil noted, this is a sweet spot around web services, not low-level communication. To implement this in WCF, you need to write a custom transport, which, like almost all low-level (channel programming), includes a lot of code. This transport will need to use sockets to understand the device protocol, and you need to somehow convert the messages from the protocol to WCF messages.

If the protocol is simple, I think the best way would be to implement a β€œclean” socket based implementation. In any case, the socket handling code (for communicating with the device) will be needed in the WCF solution, but you can create your own message types instead of following the message protocol (rather SOAP-compatible) used by WCF.

One of the advantages that you would have if you went all the way and implemented a custom WCF transport that β€œsays” that this protocol will be if you expose it to different people who are already used to the WCF way of implementation services - you will have to bear the initial (very high) cost of writing WCF transport, but later people can write services for this device using the good contract model provided by WCF.

+4
source

WCF has enough learning curve as it is, and if you need to tune in a lot of very low-level things, the curve will be steeper.

In addition, the reason the WCF was created was to let the developer not worry about the details of a lower level implementation. It sounds like you want the best of both worlds, which means you will probably spend most of your time fighting WCF to get it working the way you want.

Disclaimer: Although I have a basic understanding of WCF, I am not an expert and I may be wrong.

+2
source

Source: https://habr.com/ru/post/895281/


All Articles