Address Discovery

Discovery relies on UDP (User Datagram Protocol). Unlike TCP, UDP is a connectionless protocol, and no direct connection is required between the packet’s sender and the receiver. The client uses UDP to broadcast discovery requests for any endpoint supporting a specified contract type. Dedicated UDP discovery endpoints that the services support will receive these requests (WCF offers a standard implementation of the discovery endpoint). The implementation of the discovery endpoint, in turn, responds back to the client with the address of the service endpoints that support the specified contract. Once the client discovers the services, it continues to invoke them as with regular WCF calls. This sequence is illustrated in Figure C-1.

Address discovery over UDP

Figure C-1. Address discovery over UDP

Note

Since discovery is predicated on the service responding to the client request, the service process must be running before the client issues the request. This mandates the use of self-hosting or Windows Server AppFabric with Auto-start enabled.

Service Configuration

To receive the discovery request, the service must support a discovery endpoint. Much like the MEX endpoint, WCF offers a standard discovery endpoint with the type UdpDiscoveryEndpoint:

public class DiscoveryEndpoint : ServiceEndpoint
{...}
public class UdpDiscoveryEndpoint : DiscoveryEndpoint
{...}

The service can have the host implement ...

Get Programming WCF Services, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.