Advantages of Each Transport
This section describes the main reasons for choosing any one of the
three main transports, including a detailed decision chart for
choosing among them.
When to Use HTTP Transport
HTTP is a request/response protocol between clients and servers. The
most common application consists of Web-browser clients that
communicate with a Web server. The client sends a request to a server,
which listens for client request messages. When the server receives a
request, it returns a response, which contains the status of the
request. If successful, optional data, such as a Web page, an error
message, or other information is returned. For more information about
the HTTP protocol, see HTTP - Hypertext Transfer Protocol.
The HTTP protocol is not connection-based—once the response is sent,
no state is maintained. To handle multiple-page transactions, the
application must persist any necessary state.
In WCF, the HTTP transport binding is optimized for interoperability
with legacy non-WCF systems. If all communicating parties are using
WCF, the TCP-based or named pipes-based bindings are faster. For more
information, see NetTcpBinding and NetNamedPipeBinding.
When to Use the TCP Transport
TCP is a connection-based, stream-oriented delivery service with
end-to-end error detection and correction. Connection-based means that
a communication session between hosts is established before exchanging
data. A host is any device on a TCP/IP network identified by a logical
IP address.
TCP provides reliable data delivery and ease of use. Specifically, TCP
notifies the sender of packet delivery, guarantees that packets are
delivered in the same order in which they are sent, retransmits lost
packets, and ensures that data packets are not duplicated. Note that
this reliable delivery applies between two TCP/IP nodes, and is not
the same thing as WS-ReliableMessaging, which applies between
endpoints, no matter how many intermediate nodes they may include.
The WCF TCP transport is optimized for the scenario where both ends of
the communication are using WCF. This binding is the fastest WCF
binding for scenarios that involve communicating between different
machines. The message exchanges use the
BinaryMessageEncodingBindingElement for optimized message transfer.
TCP provides duplex communication and so can be used to implement
duplex contracts, even if the client is behind network address
translation (NAT).
When to Use the Named Pipe Transport
A named pipe is an object in the Windows operating system kernel, such
as a section of shared memory that processes can use for
communication. A named pipe has a name, and can be used for one-way or
duplex communication between processes on a single machine.
When communication is required between different WCF applications on a
single computer, and you want to prevent any communication from
another machine, then use the named pipes transport. An additional
restriction is that processes running from Windows Remote Desktop may
be restricted to the same Windows Remote Desktop session unless they
have elevated privileges.