learn-powershell.net Open in urlscan Pro
192.0.78.24  Public Scan

URL: https://learn-powershell.net/2015/02/28/checking-for-a-tcp-listener-connection/
Submission: On March 18 via manual from US — Scanned from DE

Form analysis 6 forms found in the DOM

POST https://learn-powershell.net/wp-comments-post.php

<form action="https://learn-powershell.net/wp-comments-post.php" method="post" id="commentform" class="comment-form"><input type="hidden" id="highlander_comment_nonce" name="highlander_comment_nonce" value="d2349fc6ce"><input type="hidden"
    name="_wp_http_referer" value="/2015/02/28/checking-for-a-tcp-listener-connection/">
  <input type="hidden" name="hc_post_as" id="hc_post_as" value="guest">
  <div class="comment-form-field comment-textarea">
    <div id="comment-form-comment"><textarea id="comment" name="comment" title="Enter your comment here..." placeholder="Enter your comment here..." style="overflow: hidden; overflow-wrap: break-word; resize: none; height: 38px;"></textarea></div>
  </div>
  <div id="comment-form-identity" style="display: none;">
    <div id="comment-form-nascar">
      <p>Fill in your details below or click an icon to log in:</p>
      <ul>
        <li class="selected" style="display:none;">
          <a href="#comment-form-guest" id="postas-guest" class="nascar-signin-link" title="Login via Guest">
									</a>
        </li>
        <li>
          <a href="#comment-form-load-service:WordPress.com" id="postas-wordpress" class="nascar-signin-link" title="Login via WordPress.com">
					<svg xmlns="http://www.w3.org/2000/svg" role="presentation" viewBox="0 0 24 24"><rect x="0" fill="none" width="24" height="24"></rect><g><path fill="#0087be" d="M12.158 12.786l-2.698 7.84c.806.236 1.657.365 2.54.365 1.047 0 2.05-.18 2.986-.51-.024-.037-.046-.078-.065-.123l-2.762-7.57zM3.008 12c0 3.56 2.07 6.634 5.068 8.092L3.788 8.342c-.5 1.117-.78 2.354-.78 3.658zm15.06-.454c0-1.112-.398-1.88-.74-2.48-.456-.74-.883-1.368-.883-2.11 0-.825.627-1.595 1.51-1.595.04 0 .078.006.116.008-1.598-1.464-3.73-2.36-6.07-2.36-3.14 0-5.904 1.613-7.512 4.053.21.008.41.012.58.012.94 0 2.395-.114 2.395-.114.484-.028.54.684.057.74 0 0-.487.058-1.03.086l3.275 9.74 1.968-5.902-1.4-3.838c-.485-.028-.944-.085-.944-.085-.486-.03-.43-.77.056-.742 0 0 1.484.114 2.368.114.94 0 2.397-.114 2.397-.114.486-.028.543.684.058.74 0 0-.488.058-1.03.086l3.25 9.665.897-2.997c.456-1.17.684-2.137.684-2.907zm1.82-3.86c.04.286.06.593.06.924 0 .912-.17 1.938-.683 3.22l-2.746 7.94c2.672-1.558 4.47-4.454 4.47-7.77 0-1.564-.4-3.033-1.1-4.314zM12 22C6.486 22 2 17.514 2 12S6.486 2 12 2s10 4.486 10 10-4.486 10-10 10z"></path></g></svg>				</a>
        </li>
        <li>
          <a href="#comment-form-load-service:Twitter" id="postas-twitter" class="nascar-signin-link" title="Login via Twitter">
					<svg xmlns="http://www.w3.org/2000/svg" role="presentation" viewBox="0 0 24 24"><rect x="0" fill="none" width="24" height="24"></rect><g><path fill="#1DA1F2" d="M22.23 5.924c-.736.326-1.527.547-2.357.646.847-.508 1.498-1.312 1.804-2.27-.793.47-1.67.812-2.606.996C18.325 4.498 17.258 4 16.078 4c-2.266 0-4.103 1.837-4.103 4.103 0 .322.036.635.106.935-3.41-.17-6.433-1.804-8.457-4.287-.353.607-.556 1.312-.556 2.064 0 1.424.724 2.68 1.825 3.415-.673-.022-1.305-.207-1.86-.514v.052c0 1.988 1.415 3.647 3.293 4.023-.344.095-.707.145-1.08.145-.265 0-.522-.026-.773-.074.522 1.63 2.038 2.817 3.833 2.85-1.404 1.1-3.174 1.757-5.096 1.757-.332 0-.66-.02-.98-.057 1.816 1.164 3.973 1.843 6.29 1.843 7.547 0 11.675-6.252 11.675-11.675 0-.178-.004-.355-.012-.53.802-.578 1.497-1.3 2.047-2.124z"></path></g></svg>				</a>
        </li>
        <li>
          <a href="#comment-form-load-service:Facebook" id="postas-facebook" class="nascar-signin-link" title="Login via Facebook">
					<svg xmlns="http://www.w3.org/2000/svg" role="presentation" viewBox="0 0 24 24"><rect x="0" fill="none" width="24" height="24"></rect><g><path fill="#3B5998" d="M20.007 3H3.993C3.445 3 3 3.445 3 3.993v16.013c0 .55.445.994.993.994h8.62v-6.97H10.27V11.31h2.346V9.31c0-2.325 1.42-3.59 3.494-3.59.993 0 1.847.073 2.096.106v2.43h-1.438c-1.128 0-1.346.537-1.346 1.324v1.734h2.69l-.35 2.717h-2.34V21h4.587c.548 0 .993-.445.993-.993V3.993c0-.548-.445-.993-.993-.993z"></path></g></svg>				</a>
        </li>
      </ul>
    </div>
    <div id="comment-form-guest" class="comment-form-service selected">
      <div class="comment-form-padder">
        <div class="comment-form-avatar">
          <a href="https://gravatar.com/site/signup/" target="_blank">				<img src="https://1.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=25" alt="Gravatar" width="25" class="no-grav grav-hashed grav-hijack" id="grav-ad516503a11cd5ca435acc9bb6523536-0">
</a>
        </div>
        <div class="comment-form-fields">
          <div class="comment-form-field comment-form-email">
            <label for="email">Email <span class="required">(required)</span> <span class="nopublish">(Address never made public)</span></label>
            <div class="comment-form-input"><input id="email" name="email" type="email" value=""></div>
          </div>
          <div class="comment-form-field comment-form-author">
            <label for="author">Name <span class="required">(required)</span></label>
            <div class="comment-form-input"><input id="author" name="author" type="text" value=""></div>
          </div>
          <div class="comment-form-field comment-form-url">
            <label for="url">Website</label>
            <div class="comment-form-input"><input id="url" name="url" type="url" value=""></div>
          </div>
        </div>
      </div>
    </div>
    <div id="comment-form-wordpress" class="comment-form-service">
      <div class="comment-form-padder">
        <div class="comment-form-avatar">
          <img src="https://1.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=25" alt="WordPress.com Logo" width="25" class="no-grav grav-hashed grav-hijack" id="grav-ad516503a11cd5ca435acc9bb6523536-1">
        </div>
        <div class="comment-form-fields">
          <input type="hidden" name="wp_avatar" id="wordpress-avatar" class="comment-meta-wordpress" value="">
          <input type="hidden" name="wp_user_id" id="wordpress-user_id" class="comment-meta-wordpress" value="">
          <input type="hidden" name="wp_access_token" id="wordpress-access_token" class="comment-meta-wordpress" value="">
          <p class="comment-form-posting-as pa-wordpress">
            <strong></strong> You are commenting using your WordPress.com account. <span class="comment-form-log-out"> (&nbsp;<a href="javascript:HighlanderComments.doExternalLogout( 'wordpress' );">Log&nbsp;Out</a>&nbsp;/&nbsp;
              <a href="#" onclick="javascript:HighlanderComments.switchAccount();return false;">Change</a>&nbsp;) </span>
            <span class="pa-icon"><svg xmlns="http://www.w3.org/2000/svg" role="presentation" viewBox="0 0 24 24">
                <rect x="0" fill="none" width="24" height="24"></rect>
                <g>
                  <path fill="#0087be"
                    d="M12.158 12.786l-2.698 7.84c.806.236 1.657.365 2.54.365 1.047 0 2.05-.18 2.986-.51-.024-.037-.046-.078-.065-.123l-2.762-7.57zM3.008 12c0 3.56 2.07 6.634 5.068 8.092L3.788 8.342c-.5 1.117-.78 2.354-.78 3.658zm15.06-.454c0-1.112-.398-1.88-.74-2.48-.456-.74-.883-1.368-.883-2.11 0-.825.627-1.595 1.51-1.595.04 0 .078.006.116.008-1.598-1.464-3.73-2.36-6.07-2.36-3.14 0-5.904 1.613-7.512 4.053.21.008.41.012.58.012.94 0 2.395-.114 2.395-.114.484-.028.54.684.057.74 0 0-.487.058-1.03.086l3.275 9.74 1.968-5.902-1.4-3.838c-.485-.028-.944-.085-.944-.085-.486-.03-.43-.77.056-.742 0 0 1.484.114 2.368.114.94 0 2.397-.114 2.397-.114.486-.028.543.684.058.74 0 0-.488.058-1.03.086l3.25 9.665.897-2.997c.456-1.17.684-2.137.684-2.907zm1.82-3.86c.04.286.06.593.06.924 0 .912-.17 1.938-.683 3.22l-2.746 7.94c2.672-1.558 4.47-4.454 4.47-7.77 0-1.564-.4-3.033-1.1-4.314zM12 22C6.486 22 2 17.514 2 12S6.486 2 12 2s10 4.486 10 10-4.486 10-10 10z">
                  </path>
                </g>
              </svg></span>
          </p>
        </div>
      </div>
    </div>
    <div id="comment-form-googleplus" class="comment-form-service">
      <div class="comment-form-padder">
        <div class="comment-form-avatar">
          <img src="https://1.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=25" alt="Google photo" width="25" class="no-grav grav-hashed grav-hijack" id="grav-ad516503a11cd5ca435acc9bb6523536-2">
        </div>
        <div class="comment-form-fields">
          <input type="hidden" name="googleplus_avatar" id="googleplus-avatar" class="comment-meta-googleplus" value="">
          <input type="hidden" name="googleplus_user_id" id="googleplus-user_id" class="comment-meta-googleplus" value="">
          <input type="hidden" name="googleplus_access_token" id="googleplus-access_token" class="comment-meta-googleplus" value="">
          <p class="comment-form-posting-as pa-googleplus">
            <strong></strong> You are commenting using your Google account. <span class="comment-form-log-out"> (&nbsp;<a href="javascript:HighlanderComments.doExternalLogout( 'googleplus' );">Log&nbsp;Out</a>&nbsp;/&nbsp;
              <a href="#" onclick="javascript:HighlanderComments.switchAccount();return false;">Change</a>&nbsp;) </span>
            <span class="pa-icon"><svg xmlns="http://www.w3.org/2000/svg" role="presentation" x="0px" y="0px" viewBox="0 0 60 60">
                <path fill="#519bf7" d="M56.3,30c0,-1.6 -0.2,-3.4 -0.6,-5h-3.1H42.2H30v10.6h14.8C44,39.3 42,42 39.1,43.9l8.8,6.8C53,46 56.3,39 56.3,30z"></path>
                <path fill="#3db366" d="M30,57.5c6.7,0 13.1,-2.4 17.9,-6.8l-8.8,-6.8c-2.5,1.6 -5.6,2.4 -9.1,2.4c-7.2,0 -13.3,-4.7 -15.4,-11.2l-9.3,7.1C9.8,51.3 19.1,57.5 30,57.5z"></path>
                <path fill="#fdc600" d="M5.3,42.2l9.3,-7.1c-0.5,-1.6 -0.8,-3.3 -0.8,-5.1s0.3,-3.5 0.8,-5.1l-9.3,-7.1C3.5,21.5 2.5,25.6 2.5,30S3.5,38.5 5.3,42.2z"></path>
                <path fill="#f15b44" d="M40.1,17.4l8,-8C43.3,5.1 37,2.5 30,2.5C19.1,2.5 9.8,8.7 5.3,17.8l9.3,7.1c2.1,-6.5 8.2,-11.1 15.4,-11.1C33.9,13.7 37.4,15.1 40.1,17.4z"></path>
              </svg></span>
          </p>
        </div>
      </div>
    </div>
    <div id="comment-form-twitter" class="comment-form-service">
      <div class="comment-form-padder">
        <div class="comment-form-avatar">
          <img src="https://1.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=25" alt="Twitter picture" width="25" class="no-grav grav-hashed grav-hijack" id="grav-ad516503a11cd5ca435acc9bb6523536-3">
        </div>
        <div class="comment-form-fields">
          <input type="hidden" name="twitter_avatar" id="twitter-avatar" class="comment-meta-twitter" value="">
          <input type="hidden" name="twitter_user_id" id="twitter-user_id" class="comment-meta-twitter" value="">
          <input type="hidden" name="twitter_access_token" id="twitter-access_token" class="comment-meta-twitter" value="">
          <p class="comment-form-posting-as pa-twitter">
            <strong></strong> You are commenting using your Twitter account. <span class="comment-form-log-out"> (&nbsp;<a href="javascript:HighlanderComments.doExternalLogout( 'twitter' );">Log&nbsp;Out</a>&nbsp;/&nbsp;
              <a href="#" onclick="javascript:HighlanderComments.switchAccount();return false;">Change</a>&nbsp;) </span>
            <span class="pa-icon"><svg xmlns="http://www.w3.org/2000/svg" role="presentation" viewBox="0 0 24 24">
                <rect x="0" fill="none" width="24" height="24"></rect>
                <g>
                  <path fill="#1DA1F2"
                    d="M22.23 5.924c-.736.326-1.527.547-2.357.646.847-.508 1.498-1.312 1.804-2.27-.793.47-1.67.812-2.606.996C18.325 4.498 17.258 4 16.078 4c-2.266 0-4.103 1.837-4.103 4.103 0 .322.036.635.106.935-3.41-.17-6.433-1.804-8.457-4.287-.353.607-.556 1.312-.556 2.064 0 1.424.724 2.68 1.825 3.415-.673-.022-1.305-.207-1.86-.514v.052c0 1.988 1.415 3.647 3.293 4.023-.344.095-.707.145-1.08.145-.265 0-.522-.026-.773-.074.522 1.63 2.038 2.817 3.833 2.85-1.404 1.1-3.174 1.757-5.096 1.757-.332 0-.66-.02-.98-.057 1.816 1.164 3.973 1.843 6.29 1.843 7.547 0 11.675-6.252 11.675-11.675 0-.178-.004-.355-.012-.53.802-.578 1.497-1.3 2.047-2.124z">
                  </path>
                </g>
              </svg></span>
          </p>
        </div>
      </div>
    </div>
    <div id="comment-form-facebook" class="comment-form-service">
      <div class="comment-form-padder">
        <div class="comment-form-avatar">
          <img src="" alt="Facebook photo" width="25" class="no-grav">
        </div>
        <div class="comment-form-fields">
          <input type="hidden" name="fb_avatar" id="facebook-avatar" class="comment-meta-facebook" value="">
          <input type="hidden" name="fb_user_id" id="facebook-user_id" class="comment-meta-facebook" value="">
          <input type="hidden" name="fb_access_token" id="facebook-access_token" class="comment-meta-facebook" value="">
          <p class="comment-form-posting-as pa-facebook">
            <strong></strong> You are commenting using your Facebook account. <span class="comment-form-log-out"> (&nbsp;<a href="javascript:HighlanderComments.doExternalLogout( 'facebook' );">Log&nbsp;Out</a>&nbsp;/&nbsp;
              <a href="#" onclick="javascript:HighlanderComments.switchAccount();return false;">Change</a>&nbsp;) </span>
            <span class="pa-icon"><svg xmlns="http://www.w3.org/2000/svg" role="presentation" viewBox="0 0 24 24">
                <rect x="0" fill="none" width="24" height="24"></rect>
                <g>
                  <path fill="#3B5998"
                    d="M20.007 3H3.993C3.445 3 3 3.445 3 3.993v16.013c0 .55.445.994.993.994h8.62v-6.97H10.27V11.31h2.346V9.31c0-2.325 1.42-3.59 3.494-3.59.993 0 1.847.073 2.096.106v2.43h-1.438c-1.128 0-1.346.537-1.346 1.324v1.734h2.69l-.35 2.717h-2.34V21h4.587c.548 0 .993-.445.993-.993V3.993c0-.548-.445-.993-.993-.993z">
                  </path>
                </g>
              </svg></span>
          </p>
        </div>
      </div>
    </div>
    <div id="comment-form-load-service" class="comment-form-service">
      <div class="comment-form-posting-as-cancel"><a href="javascript:HighlanderComments.cancelExternalWindow();">Cancel</a></div>
      <p>Connecting to %s</p>
    </div>
  </div>
  <script type="text/javascript">
    var highlander_expando_javascript = function() {
      function hide(sel) {
        var el = document.querySelector(sel);
        if (el) {
          el.style.setProperty('display', 'none');
        }
      }

      function show(sel) {
        var el = document.querySelector(sel);
        if (el) {
          el.style.removeProperty('display');
        }
      }
      var input = document.createElement('input');
      var comment = document.querySelector('#comment');
      if (input && comment && 'placeholder' in input) {
        var label = document.querySelector('.comment-textarea label');
        if (label) {
          var text = label.textContent;
          label.parentNode.removeChild(label);
          comment.setAttribute('placeholder', text);
        }
      }
      // Expando Mode: start small, then auto-resize on first click + text length
      hide('#comment-form-identity');
      hide('#comment-form-subscribe');
      hide('#commentform .form-submit');
      if (comment) {
        comment.style.height = '10px';
        var handler = function() {
          comment.style.height = HighlanderComments.initialHeight + 'px';
          show('#comment-form-identity');
          show('#comment-form-subscribe');
          show('#commentform .form-submit');
          HighlanderComments.resizeCallback();
          comment.removeEventListener('focus', handler);
        };
        comment.addEventListener('focus', handler);
      }
    }
    if (document.readyState !== 'loading') {
      highlander_expando_javascript();
    } else {
      document.addEventListener('DOMContentLoaded', highlander_expando_javascript);
    }
  </script>
  <div id="comment-form-subscribe" style="display: none;">
    <p class="comment-subscription-form"><input type="checkbox" name="subscribe" id="subscribe" value="subscribe" style="width: auto;"> <label class="subscribe-label" id="subscribe-label" for="subscribe" style="display: inline;">Notify me of new
        comments via email.</label></p>
    <p class="post-subscription-form"><input type="checkbox" name="subscribe_blog" id="subscribe_blog" value="subscribe" style="width: auto;"> <label class="subscribe-label" id="subscribe-blog-label" for="subscribe_blog"
        style="display: inline;">Notify me of new posts via email.</label></p>
  </div>
  <p class="form-submit" style="display: none;"><input name="submit" type="submit" id="comment-submit" class="submit" value="Post Comment"> <input type="hidden" name="comment_post_ID" value="5774" id="comment_post_ID">
    <input type="hidden" name="comment_parent" id="comment_parent" value="0">
  </p>
  <p style="display: none;"><input type="hidden" id="akismet_comment_nonce" name="akismet_comment_nonce" value="77ae0978e6"></p>
  <input type="hidden" name="genseq" value="1647625497">
  <p style="display: none !important;"><label>Δ<textarea name="ak_hp_textarea" cols="45" rows="8" maxlength="100"></textarea></label><input type="hidden" id="ak_js_1" name="ak_js" value="1647625497749">
    <script>
      document.getElementById("ak_js_1").setAttribute("value", (new Date()).getTime());
    </script>
  </p>
</form>

GET https://learn-powershell.net/

<form role="search" method="get" id="searchform" class="searchform" action="https://learn-powershell.net/">
  <div>
    <label class="screen-reader-text" for="s">Search for:</label>
    <input type="text" value="" name="s" id="s">
    <input type="submit" id="searchsubmit" value="Search">
  </div>
</form>

GET https://learn-powershell.net

<form action="https://learn-powershell.net" method="get"><label class="screen-reader-text" for="cat">Categories</label><select name="cat" id="cat" class="postform">
    <option value="-1">Select Category</option>
    <option class="level-0" value="162381199">2013 Scripting Games Judges Notes</option>
    <option class="level-0" value="238274551">Debug</option>
    <option class="level-0" value="282714">Deep Dive</option>
    <option class="level-0" value="7744666">Excel</option>
    <option class="level-0" value="7168">GUI</option>
    <option class="level-0" value="31428">Modules</option>
    <option class="level-0" value="103">News</option>
    <option class="level-0" value="315">Office</option>
    <option class="level-0" value="19743086">PowerCLI</option>
    <option class="level-0" value="178495">powershell</option>
    <option class="level-0" value="56726985">Scripting Games 2011</option>
    <option class="level-0" value="82426987">Scripting Games 2012</option>
    <option class="level-0" value="159555771">Scripting Games 2013</option>
    <option class="level-0" value="4493">scripts</option>
    <option class="level-0" value="10346">SQL</option>
    <option class="level-0" value="456880">Tech-Ed</option>
    <option class="level-0" value="10118394">Tips</option>
    <option class="level-0" value="1">Uncategorized</option>
    <option class="level-0" value="31441">V3</option>
    <option class="level-0" value="694088">V4</option>
    <option class="level-0" value="23664898">V5</option>
    <option class="level-0" value="38600">VMWare</option>
    <option class="level-0" value="205592021">Winter Scripting Games 2014</option>
    <option class="level-0" value="46652">WPF</option>
    <option class="level-0" value="347217">WSUS</option>
  </select>
</form>

POST https://subscribe.wordpress.com

<form action="https://subscribe.wordpress.com" method="post" accept-charset="utf-8" id="subscribe-blog">
  <p>Enter your email address to subscribe to this blog and receive notifications of new posts by email.</p>
  <div class="jetpack-subscribe-count">
    <p> Join 475 other followers </p>
  </div>
  <p id="subscribe-email">
    <label id="subscribe-field-label" for="subscribe-field" class="screen-reader-text"> Email Address: </label>
    <input type="email" name="email" style="width: 95%; padding: 1px 10px" placeholder="Enter your email address" value="" id="subscribe-field">
  </p>
  <p id="subscribe-submit">
    <input type="hidden" name="action" value="subscribe">
    <input type="hidden" name="blog_id" value="15063622">
    <input type="hidden" name="source" value="https://learn-powershell.net/2015/02/28/checking-for-a-tcp-listener-connection/">
    <input type="hidden" name="sub-type" value="widget">
    <input type="hidden" name="redirect_fragment" value="subscribe-blog">
    <input type="hidden" id="_wpnonce" name="_wpnonce" value="e3523f0e2d"> <button type="submit" class="wp-block-button__link"> Sign me up! </button>
  </p>
</form>

POST https://subscribe.wordpress.com

<form method="post" action="https://subscribe.wordpress.com" accept-charset="utf-8" style="display: none;">
  <div class="actnbr-follow-count">Join 475 other followers</div>
  <div>
    <input type="email" name="email" placeholder="Enter your email address" class="actnbr-email-field" aria-label="Enter your email address">
  </div>
  <input type="hidden" name="action" value="subscribe">
  <input type="hidden" name="blog_id" value="15063622">
  <input type="hidden" name="source" value="https://learn-powershell.net/2015/02/28/checking-for-a-tcp-listener-connection/">
  <input type="hidden" name="sub-type" value="actionbar-follow">
  <input type="hidden" id="_wpnonce" name="_wpnonce" value="e3523f0e2d">
  <div class="actnbr-button-wrap">
    <button type="submit" value="Sign me up"> Sign me up </button>
  </div>
</form>

POST /2015/02/28/checking-for-a-tcp-listener-connection/

<form action="/2015/02/28/checking-for-a-tcp-listener-connection/" method="post">
  <label for="target_email">Send to Email Address</label>
  <input type="email" name="target_email" id="target_email" value="">
  <label for="source_name">Your Name</label>
  <input type="text" name="source_name" id="source_name" value="">
  <label for="source_email">Your Email Address</label>
  <input type="email" name="source_email" id="source_email" value="">
  <input type="text" id="jetpack-source_f_name" name="source_f_name" class="input" value="" size="25" autocomplete="off" title="This field is for validation and should not be changed">
  <div class="g-recaptcha" data-sitekey="6LcmyE0UAAAAALID28yVNg7pFCodGaArJzHitez_" data-theme="light" data-type="image" data-tabindex="0" data-lazy="true" data-url="https://www.google.com/recaptcha/api.js?hl=en"></div>
  <img style="float: right; display: none" class="loading" src="https://s0.wp.com/wp-content/mu-plugins/post-flair/sharing/images/loading.gif" alt="loading" width="16" height="16">
  <input type="submit" value="Send Email" class="sharing_send">
  <a rel="nofollow" href="#cancel" class="sharing_cancel" role="button">Cancel</a>
  <div class="errors errors-1" style="display: none;"> Post was not sent - check your email addresses! </div>
  <div class="errors errors-2" style="display: none;"> Email check failed, please try again </div>
  <div class="errors errors-3" style="display: none;"> Sorry, your blog cannot share posts by email. </div>
</form>

Text Content

Learn Powershell | Achieve More
What is this Powershell of which you speak?
Skip to content
 * Home
 * About
 * Articles
 * PowerShell Forum Directory
 * Projects
 * Publications
 * Scripts
 * Speaking

← A Look at Filtering Performance in PowerShell
MCPMag Articles on Exploring PowerShell →


CHECKING FOR A TCP LISTENER CONNECTION

Posted on February 28, 2015 by Boe Prox

I’ve been spending some time re-writing my PoshChat project to replace various
things that I feel could have been written better as well as trying to knock out
some of the issues that I had in the beginning but just never got around to
fixing. One of those items was how I was using the
System.Net.Sockets.TcpListener and setting it up to listen for new connections
and then handling those connections (usually in another runspace) so I still
have the room to handle other new connections.

The ‘Old” Way

The big issue here is that I was using the AcceptTCPClient() method, which
presents a blocking call on the console. This means that I cannot do anything
else at all, which really wasn’t an issue for me because I had all of this
operating in its own runspace. The code snippet below shows the setting up of
the runspace that will be handling the listener as well as when connections
happen.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$SharedData = [HashTable]::Synchronized(@{})
$Listener = [HashTable]::Synchronized(@{})
 
#Initial runspace creation to set up server listener
$NewRunspace = [RunSpaceFactory]::CreateRunspace()
$NewRunspace.Open()
$NewRunspace.SessionStateProxy.setVariable(&amp;quot;sharedData&amp;quot;,
$sharedData)
$NewRunspace.SessionStateProxy.setVariable(&amp;quot;Listener&amp;quot;,
$Listener)
$NewPowerShell = [PowerShell]::Create()
$NewPowerShell.Runspace = $NewRunspace
$sb = {
     $Listener['listener'] = [System.Net.Sockets.TcpListener]15600
     $Listener['listener'].Start()
    while($true) {
    [byte[]]$byte = New-Object byte[] 1024
    $client = $Listener['listener'].AcceptTcpClient()
    If ($client -ne $Null) {
        $stream = $client.GetStream()
        # ... #
    } Else {
        #Connection to server closed
        Break
    }
    }#End While
}
$Handle = $NewPowerShell.AddScript($sb).BeginInvoke()

You can see where I begin using AcceptTCPClient() which presents the blocking
call. What happens is that at this point I have no way to break out of this
call. Even if I were to change the $True to $False in my While() {} statement,
it wouldn’t matter because of the blocking call. Obviously, this presents an
issue if I wanted to halt my chat server which would mean completely halting the
PowerShell process to effectively stop the listener.

The “New” Way using Pending()

The solution that I have found involves using the Pending() method of the
listener object. By still using a loop and instead calling the Pending() method
which will return $True for a connection that is attempting to be made to the
listener and $False if no connections are being attempted, we can keep from
blocking the runspace and allow us to inject a variable update to halt the loop
if we wanted to shut down the server. Let’s give it a shot and see what happens.

First we need to start out listener:

1
2
3
#Create the listener and kick it off
$Listener = [System.Net.Sockets.TcpListener]15600
$Listener.Start()



Ok, now if we check for pending connections, we will get back a False, meaning
that there are no connections currently being attempted.

1
$Listener.Pending()



Since that is the case, I would simply start a sleep cycle for a second and
check again. But now let’s assume that a connection was attempted (using the
code below) and we can check again to see what happens.

1
2
3
4
5
#Connect to server
$Server = 'Boe-PC'
$Endpoint = new-object System.Net.IPEndpoint ([ipaddress]::any,$SourcePort)
$Client = [Net.Sockets.TCPClient]$endpoint 
$Client.Connect($Server,15600)

Now we can check for pending connection attempts.



Looks like we have a connection being made, so we had better act on it by
calling the AcceptTCPClient() method. We also can open up a stream during this
process as well.

1
2
3
4
5
$Client = $Listener.AcceptTcpClient()
$ClientConnections = $Client 
$ClientStream = $Client.GetStream()        
Write-Verbose (&amp;quot;[$(Get-Date)] New Connection from {0}
&amp;lt;{1}&amp;gt;!&amp;quot; -f
$Client.Client.RemoteEndPoint.Address, $Client.Client.RemoteEndPoint.Port)
–Verbos

e



Perfect! Now we can begin doing whatever should be done with this new
connection. In this case, I am not going to do anything with it, but in
PoshChat, this would get handed off to another runspace to handle the client
connection and stream for messaging and the listener would be back watching for
new connections.

By watching for Pending() connections, we avoid being blocked by the
AcceptTCPClient() method and can then easily close our listener up without
completely trashing our current PowerShell console.

Hopefully this approach helps you out if you happen to be working with client
connections to a listener and provides a way to more easily handle tracking
those new connections to the listener without completely taking away your
ability to shut down the listener.


SHARE THIS:

 * Twitter
 * Facebook
 * Email
 * LinkedIn
 * Reddit
 * Pocket
 * 


LIKE THIS:

Like Loading...


RELATED

PowerShell and WPF: Writing Data to a UI From a Different RunspaceOctober 14,
2012In "powershell"

Sharing Variables and Live Objects Between PowerShell RunspacesApril 19, 2013In
"powershell"

Using Background Runspaces Instead of PSJobs For Better PerformanceMay 13,
2012In "powershell"

This entry was posted in powershell and tagged .net, listener, Powershell, tcp.
Bookmark the permalink.
← A Look at Filtering Performance in PowerShell
MCPMag Articles on Exploring PowerShell →


1 RESPONSE TO CHECKING FOR A TCP LISTENER CONNECTION

 1. dineshramitc says:
    March 1, 2015 at 8:13 pm
    
    Reblogged this on Dinesh Ram Kali..
    
    Reply
    


LEAVE A REPLY CANCEL REPLY

Fill in your details below or click an icon to log in:

 * 
 * 
 * 
 * 

Email (required) (Address never made public)

Name (required)

Website


You are commenting using your WordPress.com account. ( Log Out /  Change )

You are commenting using your Google account. ( Log Out /  Change )

You are commenting using your Twitter account. ( Log Out /  Change )

You are commenting using your Facebook account. ( Log Out /  Change )

Cancel

Connecting to %s

Notify me of new comments via email.

Notify me of new posts via email.





Δ


 * 


 * OMAHA POWERSHELL USERS GROUP


 * BOOKS


 * 2013 POWERSHELL SCRIPTING GAMES


 * TRANSLATE THIS BLOG
   
   Translate this blog into different languages...
   
   العربية
   Български
   中文(简体)
   中文(繁體)
   Hrvatski
   Česky
   Dansk
   Nederlands
   Suomi
   Français
   Deutsch
   Ελληνική
   हिन्दी
   Italiano
   日本語
   한국어
   Norsk
   Polski
   Português
   Română
   Русский
   Español
   Svenska
 * Search for:


 * RECENT POSTS
   
   * Dealing with Runspacepool Variable Scope Creep in PowerShell
   * 2018 PowerShell Resolutions
   * Quick Hits: Getting the Local Computer Name
   * Recent Articles on MCPMag
   * Quick Hits: Finding all Hyperlinks in an Excel Workbook


 * TOP POSTS
   
   * Changing Ownership of File or Folder Using PowerShell
   * Starting,Stopping and Restarting Remote Services with PowerShell
   * Avoiding System.Object[] (or Similar Output) when using Export-Csv
   * Querying UDP Ports with PowerShell
   * Setting up Local Administrator Password Solution (LAPS)
   * Locating Mount Points Using PowerShell
   * PowerShell and Excel: Adding Some Formatting To Your Report
   * Building a Chart Using PowerShell and Chart Controls
   * Getting the Icon from a File Using PowerShell
   * Quick Hits: Finding Exception Types with PowerShell


 * ARCHIVES
   
   Archives Select Month January 2018  (1) December 2017  (1) September 2017
    (1) July 2017  (2) May 2017  (2) April 2017  (1) February 2017  (2) January
   2017  (1) December 2016  (2) November 2016  (2) October 2016  (2) September
   2016  (2) August 2016  (3) July 2016  (2) June 2016  (2) May 2016  (2) April
   2016  (3) March 2016  (3) February 2016  (2) January 2016  (3) December 2015
    (3) November 2015  (3) October 2015  (5) September 2015  (3) August 2015
    (3) July 2015  (2) June 2015  (3) May 2015  (4) April 2015  (3) March 2015
    (5) February 2015  (4) January 2015  (3) December 2014  (4) November 2014
    (4) October 2014  (4) September 2014  (4) August 2014  (5) July 2014  (2)
   June 2014  (5) May 2014  (4) April 2014  (6) March 2014  (5) February 2014
    (3) January 2014  (7) December 2013  (6) November 2013  (3) October 2013
    (9) September 2013  (6) August 2013  (7) July 2013  (8) June 2013  (4) May
   2013  (9) April 2013  (12) March 2013  (5) February 2013  (7) January 2013
    (7) December 2012  (7) November 2012  (6) October 2012  (5) September 2012
    (2) August 2012  (6) July 2012  (2) June 2012  (7) May 2012  (4) April 2012
    (8) March 2012  (10) February 2012  (2) January 2012  (5) December 2011  (2)
   November 2011  (1) October 2011  (2) September 2011  (6) August 2011  (4)
   July 2011  (3) June 2011  (4) May 2011  (4) April 2011  (1) March 2011  (4)
   February 2011  (8) January 2011  (6) November 2010  (3) October 2010  (5)
   September 2010  (5) August 2010  (7)


 * CATEGORIES
   
   Categories Select Category 2013 Scripting Games Judges Notes Debug Deep Dive
   Excel GUI Modules News Office PowerCLI powershell Scripting Games 2011
   Scripting Games 2012 Scripting Games 2013 scripts SQL Tech-Ed Tips
   Uncategorized V3 V4 V5 VMWare Winter Scripting Games 2014 WPF WSUS

 * * .net
   * api
   * array
   * background jobs
   * binary
   * book
   * c#
   * clock
   * codeplex
   * com object
   * convert
   * CTP
   * database
   * deep dive
   * excel
   * Favorites
   * function
   * groups
   * guest blog
   * hash table
   * Internet Explorer
   * ise
   * mcpmag
   * module
   * MVP
   * network
   * news
   * parameter
   * patches
   * performance
   * pinvoke
   * podcast
   * port
   * PoshChat
   * poshpaig
   * PoshRSJob
   * poshwsus
   * powercli
   * powerscripting
   * Powershell
   * printers
   * quickhits
   * reflection
   * regex
   * registry
   * Regular Expressions
   * report
   * resolution
   * runspace
   * runspaces
   * scripting games 2012
   * scripting games 2013
   * scripting guy
   * scripts
   * SMO
   * Speaker
   * speaking
   * SQL
   * tcp
   * tips
   * tsql
   * updates
   * user group
   * V3
   * V4
   * v5
   * weather
   * widget
   * win32API
   * winter scriting games 2014
   * wmi
   * word
   * WPF
   * wsus
   * xaml


 * BLOGROLL
   
   * Francois-Xavier Cat PowerShell Blog
   * Jeff Hicks Powershell Blog
   * Microsoft Script Center
   * Mike Robbins Blog
   * Oliver Lipkau's Powershell Blog
   * Powerscripting Podcast
   * PowerShell Survival Guide
   * Powershell Team Blog
   * Powershell.Com
   * PowerShell.org
   * Sean Kearney's Powershell Blog
   * Shay Levi's Powershell Blog
   * Technet Powershell Forum
   * Technet Scripting Guys Forum
   * WSUS Administrator Module


 * EMAIL SUBSCRIPTION
   
   Enter your email address to subscribe to this blog and receive notifications
   of new posts by email.
   
   Join 475 other followers
   
   Email Address:
   
   Sign me up!


 * LATEST TECHNET ACTIVITY
   
   * Contributed a helpful post to the Using start-job -scriptblock to run
     script; need help using parameters thread in the The Official Scripting
     Guys Forum! Forum.
   * Contributed a helpful post to the Script to set the Primary DNS Suffix
     thread in the The Official Scripting Guys Forum! Forum.


 * TWITTER FEED
   
   * @BWWings If there is one guarantee, it is that my food is never on time for
     pickup. 11 months ago
   * @CoxHelp Appreciate the update! 11 months ago
   * @CoxHelp Hope we get service back sometime tonight. Been down since at
     least 3:45pm. https://t.co/D50GSc7BLZ 11 months ago
   * @nfmtweets Do you do haul away for old couches as part of any service for
     delivering a new couch we buy? 1 year ago
   * @Garmin Any reason why my fenix 6x that had 8 days of battery life would
     die 25 minutes into a treadmill run and sh… twitter.com/i/web/status/1…
     1 year ago


 * BLOG STATS
   
   * 4,934,138 Visitors Since August 5, 2010


 * META
   
   * Register
   * Log in
   * Entries feed
   * Comments feed
   * WordPress.com

 * 

Learn Powershell | Achieve More
Blog at WordPress.com.

 * Follow Following
    * Learn Powershell | Achieve More
      Join 475 other followers
      
      Sign me up
    * Already have a WordPress.com account? Log in now.

 *  * Learn Powershell | Achieve More
    * Customize
    * Follow Following
    * Sign up
    * Log in
    * Copy shortlink
    * Report this content
    * View post in Reader
    * Manage subscriptions
    * Collapse this bar

%d bloggers like this:
Send to Email Address Your Name Your Email Address

Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.