In Wcf , there are many types of bindings for tranferring the messages.(HTTPBinding and TCP binding). But to the knowledge I learn from university, TCP is on the transport layer, so if we use TCP binding, what is the application layer protocol?
Related
In WCF, you can create a one-way TCP Connection. How is this different from UDP?
Regarding WCF, [OperationContract(IsOneWay=true)] means that the method will not block until a response/acknowledgement appears from the callee. The underlying protocol is nonetheless TCP with all the nice features like retry, error checking etc.
See also the MSDN example
I have read about transport schemes supported by WCF several times. It looks very theoretical.Almost everywhere it is described as:
Following are the transport schemes supported by WCF:
HTTP/HTTPS - http://localhost:8001/MyService
TCP - net.tcp://localhost:8002/MyService
IPC - net.pipe://localhost/MyPipe
Peer network
MSMQ - net.msmq://localhost/private/MyQueue
Service bus - sb://MyNamespace.servicebus.windows.net/
However I could not understand who would require to consume WCF over TCP or IPC or MSMQ. Can anyone give a practical example of who would really need to consume WCF over TCP or any other sceme than HTTP and how would they do so?
Consuming a WCF-Service over TCP is in my case the most common way if you want two or more Programs to communicate. WCF over tcp can easily replace IPC-Communication.
For example:
You have a Windows-Service hosting an WCF-Service. With Vista and later you have to deal with the Session 0 isolation.
You now want to communiacte with that WCF-Service. A common way to achieve that is a tray-application.
Most Anti-Virus programs do it like this.
If you are operating on the same machine, tcp is way faster than HTTP-Binding.
I have found Tim's comments very useful. I have gone through the link he had provided and I will try to summarize whatever I have got from it.
When to use TCP - When host is WCF and consumer is WCF as well use TCP. The communication would be much faster than HTTP.
When to use Named pipes - When host and consumer both are WCF and reside on same machine. The communication would be faster and the
access to the host would be denied from other machines.
You can refer this image for more details about choosing appropriate transport. To dig down further refer this.
Do tcp sockets have a built in method for calculating data corruption?
Thanks
Yes, the TCP protocol has a checksum. That checksum is small and using a weak algorithm, though. You cannot trust it with your life. It might be enough for youm or not. There are papers about it failing.
Note that sockets are a distinct concept from the TCP protocol. I assume you meant TCP, not sockets.
I am using a TCP port with WCF service. I have hardware that sends ASCII messages throw TCP port.
I have already implemented WCF service, I need to add TCP endpoint to it to listen this port, getting ASCII message then makes some processing on it.
Is that possible?
WCF won't help you in this scenario as it supports only SOAP messages.
SOAP is a protocol specification for exchanging information in WCF/Web Services and relies on XML for its message format.
You can not use WCF as a traditionnal tcp server to parse ASCII messages. These messages have to be structured.
Can we use net.TCP binding to implement GZip in WCF or it can only be configured with Http and WsHttp bindings.
I don't believe WCF supports GZip encoding using a TCP socket binding, however there is nothing stopping you sending GZiped compressed data over the wire, and manually compressing it using the methods built into the .NET framework: http://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream.aspx.
Before you go down this route however, I would strongly recommend assesing other performance enhancing measures on your TCP services as detailed here: Transmitting the least amount of data over the wire with WCF
Wcf 4.5 RC support message encoder out of box
http://msdn.microsoft.com/en-us/library/aa751889(v=vs.110).aspx