{"id":104,"date":"2006-03-17T14:26:25","date_gmt":"2006-03-17T21:26:25","guid":{"rendered":"http:\/\/kennyw.com\/indigo\/104"},"modified":"2006-03-17T14:26:25","modified_gmt":"2006-03-17T21:26:25","slug":"creating-a-service-on-any-free-port","status":"publish","type":"post","link":"https:\/\/kennyw.com\/?p=104","title":{"rendered":"Creating a Service on &quot;any free port&quot;"},"content":{"rendered":"<p>By default, when creating a ServiceHost we require you to specify a base address (e.g. &#8220;http:\/\/kennyw.com\/myService\/&#8221;). This is because your clients needs to know where to send messages to.  Sometimes you have a situation where you don&#8217;t need to know the exact address up front (let&#8217;s say you are using WS-Discovery or some other registry-based lookup).  In that case, you want to indicate to the transport to &#8220;use any free port&#8221; (or &#8220;port 0&#8221; in sockets-speak).  Fortunately, Indigo has this functionality baked into our addressing parameters.<\/p>\n<p>To signal you want this behavior, set <code>ServiceEndpoint.ListenUriMode<\/code> to <code class=\"classname\">ListenUriMode<\/code><code>.Unique<\/code> (the default is <code class=\"classname\">ListenUriMode<\/code><code>.Explicit<\/code>).  At build time this will propagate to <code>BindingContext.ListenUriMode<\/code>, which will then cause the Transport to &#8220;unique-ify&#8221; the ListenUriBaseAddress.<\/p>\n<p>For exclusive TCP (where the process is directly listening on a socket) we will bind to a uniquely available port#.  For shared TCP, Pipes, and HTTP we will append a GUID to the base address which will uniquely identify this endpoint. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>By default, when creating a ServiceHost we require you to specify a base address (e.g. &#8220;http:\/\/kennyw.com\/myService\/&#8221;). This is because your clients needs to know where to send messages to. Sometimes you have a situation where you don&#8217;t need to know the exact address up front (let&#8217;s say you are using WS-Discovery or some other registry-based [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-104","post","type-post","status-publish","format-standard","hentry","category-indigo"],"_links":{"self":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/posts\/104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=104"}],"version-history":[{"count":0,"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/posts\/104\/revisions"}],"wp:attachment":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}