New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tcp-emit-server

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tcp-emit-server

TCP Socket Server Based Event Emitter

  • 0.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source
tcp-emit-server/README.md at master · claytonbez/tcp-emit-server
<meta property="og:image" content="https://avatars0.githubusercontent.com/u/6775201?s=400&amp;v=4" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="claytonbez/tcp-emit-server" /><meta property="og:url" content="https://github.com/claytonbez/tcp-emit-server" /><meta property="og:description" content="tcp-emit-server - A TCP Socket Based Event Emitter" />
<meta name="google-site-verification" content="KT5gs8h0wvaagLKAVWq8bbeNwnZZK1r1XQysX3xurLU">

  <meta name="hostname" content="github.com">
<meta name="user-login" content="claytonbez">

  <meta name="expected-hostname" content="github.com">
<meta name="js-proxy-site-detection-payload" content="NzcxNTFmNTk0MmEwZmQ0MjZiMTczMzU3MzNmZTYyZGJlNzU4MWI3YWQ2ZGY2ODk4ZjgwNWVkYjg1OWI0MzYyZHx7InJlbW90ZV9hZGRyZXNzIjoiMTU0LjExOS41Ny4yMzAiLCJyZXF1ZXN0X2lkIjoiRTNERTo2ODZEOkMwNjRDNjoxNkZEQzQ4OjVCMzhFNTRCIiwidGltZXN0YW1wIjoxNTMwNDU1MzcyLCJob3N0IjoiZ2l0aHViLmNvbSJ9">

<meta name="enabled-features" content="UNIVERSE_BANNER,FREE_TRIALS,MARKETPLACE_INSIGHTS,MARKETPLACE_SEARCH,MARKETPLACE_INSIGHTS_CONVERSION_PERCENTAGES">
  <link href="https://github.com/claytonbez/tcp-emit-server/commits/master.atom" rel="alternate" title="Recent Commits to tcp-emit-server:master" type="application/atom+xml">

<link rel="canonical" href="https://github.com/claytonbez/tcp-emit-server/blob/master/README.md" data-pjax-transient>
Skip to content
  </div>

</div>

<div class="HeaderMenu d-flex flex-justify-between flex-auto">
  <div class="d-flex">
        <div class="">
          <div class="header-search scoped-search site-scoped-search js-site-search position-relative js-jump-to"

role="search combobox" aria-owns="jump-to-results" aria-label="Search or jump to" aria-haspopup="listbox" aria-expanded="true"

        <div class="Box position-absolute overflow-hidden d-none jump-to-suggestions js-jump-to-suggestions-container">
          <ul class="d-none js-jump-to-suggestions-template-container">
            <li class="d-flex flex-justify-start flex-items-center p-0 f5 navigation-item js-navigation-item">
              <a tabindex="-1" class="no-underline d-flex flex-auto flex-items-center p-2 jump-to-suggestions-path js-jump-to-suggestion-path js-navigation-open" href="">
                <div class="jump-to-octicon js-jump-to-octicon mr-2 text-center d-none"></div>
                <img class="avatar mr-2 flex-shrink-0 js-jump-to-suggestion-avatar" alt="" aria-label="Team" src="" width="28" height="28">

                <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden no-wrap css-truncate css-truncate-target">
                </div>

                <div class="border rounded-1 flex-shrink-0 bg-gray px-1 text-gray-light ml-1 f6 d-none js-jump-to-badge-search">
                  <span class="js-jump-to-badge-search-text-default d-none" aria-label="in this repository">
                    In this repository
                  </span>
                  <span class="js-jump-to-badge-search-text-global d-none" aria-label="in all of GitHub">
                    All GitHub
                  </span>
                  <span aria-hidden="true" class="d-inline-block ml-1 v-align-middle">↵</span>
                </div>

                <div aria-hidden="true" class="border rounded-1 flex-shrink-0 bg-gray px-1 text-gray-light ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump">
                  Jump to
                  <span class="d-inline-block ml-1 v-align-middle">↵</span>
                </div>
              </a>
            </li>
            <svg height="16" width="16" class="octicon octicon-repo flex-shrink-0 js-jump-to-repo-octicon-template" title="Repository" aria-label="Repository" viewBox="0 0 12 16" version="1.1" role="img"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"/></svg>
            <svg height="16" width="16" class="octicon octicon-project flex-shrink-0 js-jump-to-project-octicon-template" title="Project" aria-label="Project" viewBox="0 0 15 16" version="1.1" role="img"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 0 0-1 1v14a1 1 0 0 0 1 1h13a1 1 0 0 0 1-1V1a1 1 0 0 0-1-1z"/></svg>
            <svg height="16" width="16" class="octicon octicon-search flex-shrink-0 js-jump-to-search-octicon-template" title="Search" aria-label="Search" viewBox="0 0 16 16" version="1.1" role="img"><path fill-rule="evenodd" d="M15.7 13.3l-3.81-3.83A5.93 5.93 0 0 0 13 6c0-3.31-2.69-6-6-6S1 2.69 1 6s2.69 6 6 6c1.3 0 2.48-.41 3.47-1.11l3.83 3.81c.19.2.45.3.7.3.25 0 .52-.09.7-.3a.996.996 0 0 0 0-1.41v.01zM7 10.7c-2.59 0-4.7-2.11-4.7-4.7 0-2.59 2.11-4.7 4.7-4.7 2.59 0 4.7 2.11 4.7 4.7 0 2.59-2.11 4.7-4.7 4.7z"/></svg>
          </ul>
          <ul class="d-none js-jump-to-no-results-template-container">
            <li class="d-flex flex-justify-center flex-items-center p-3 f5 d-none">
              <span class="text-gray">No suggested jump to results</span>
            </li>
          </ul>

          <ul id="jump-to-results" class="js-navigation-container jump-to-suggestions-results-container js-jump-to-suggestions-results-container" >
            <li class="d-flex flex-justify-center flex-items-center p-0 f5">
              <img src="https://assets-cdn.github.com/images/spinners/octocat-spinner-128.gif" alt="Octocat Spinner Icon" class="m-2" width="28">
            </li>
          </ul>
        </div>
  </label>
        </div>

      <ul class="d-flex pl-2 flex-items-center text-bold list-style-none" role="navigation">
        <li>
          <a class="js-selected-navigation-item HeaderNavlink px-2" data-hotkey="g p" data-ga-click="Header, click, Nav menu - item:pulls context:user" aria-label="Pull requests you created" data-selected-links="/pulls /pulls/assigned /pulls/mentioned /pulls" href="/pulls">
            Pull requests

  • Issues
  • Marketplace
  • Explore
  •   <div class="d-flex">
        
    
    • <a aria-label="You have no unread notifications" class="notification-indicator tooltipped tooltipped-s  js-socket-channel js-notification-indicator" data-hotkey="g n" data-ga-click="Header, go to notifications, icon:read" data-channel="notification-changed:6775201" href="/notifications">
          <span class="mail-status "></span>
          <svg class="octicon octicon-bell" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M13.99 11.991v1H0v-1l.73-.58c.769-.769.809-2.547 1.189-4.416.77-3.767 4.077-4.996 4.077-4.996 0-.55.45-1 .999-1 .55 0 1 .45 1 1 0 0 3.387 1.229 4.156 4.996.38 1.879.42 3.657 1.19 4.417l.659.58h-.01zM6.995 15.99c1.11 0 1.999-.89 1.999-1.999H4.996c0 1.11.89 1.999 1.999 1.999z"/></svg>
      
    •   <ul class="dropdown-menu dropdown-menu-sw">
          
      
      New repository Import repository New gist New organization
      This repository
      New issue
        </ul>
      </details>
      
    • <details class="details-overlay details-reset js-dropdown-details d-flex pl-2 flex-items-center">
        <summary class="HeaderNavlink name mt-1"
          aria-label="View profile and more"
          data-ga-click="Header, show menu, icon:avatar">
          <img alt="@claytonbez" class="avatar float-left mr-1" src="https://avatars0.githubusercontent.com/u/6775201?s=40&amp;v=4" height="20" width="20">
          <span class="dropdown-caret"></span>
        </summary>
      
        <ul class="dropdown-menu dropdown-menu-sw">
          <li class="dropdown-header header-nav-current-user css-truncate">
            Signed in as <strong class="css-truncate-target">claytonbez</strong>
          </li>
      
          <li class="dropdown-divider"></li>
      
          <li><a class="dropdown-item" href="/claytonbez" data-ga-click="Header, go to profile, text:your profile">
            Your profile
          </a></li>
          <li><a class="dropdown-item" href="/claytonbez?tab=stars" data-ga-click="Header, go to starred repos, text:your stars">
            Your stars
          </a></li>
            <li><a class="dropdown-item" href="https://gist.github.com/" data-ga-click="Header, your gists, text:your gists">Your gists</a></li>
      
          <li class="dropdown-divider"></li>
      
          <li><a class="dropdown-item" href="https://help.github.com" data-ga-click="Header, go to help, text:help">
            Help
          </a></li>
      
          <li><a class="dropdown-item" href="/settings/profile" data-ga-click="Header, go to settings, icon:settings">
            Settings
          </a></li>
      
          <li><!-- '"` --><!-- </textarea></xmp> --></option></form><form class="logout-form" action="/logout" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><input type="hidden" name="authenticity_token" value="b+m+ktiqeO3q2SVO9tdAvlcjcWN3+MIVG9+p3XNZuNn9iPB2QRAFqdPcahcFDdmKS9x8UiLxWp9eFnKiy7qdrQ==" />
            <button type="submit" class="dropdown-item dropdown-signout" data-ga-click="Header, sign out, icon:logout">
              Sign out
            </button>
          </form></li>
        </ul>
      </details>
      
        <!-- '"` --><!-- </textarea></xmp> --></option></form><form class="sr-only right-0" action="/logout" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><input type="hidden" name="authenticity_token" value="jRNFrMqkDEXcefAhYovyBYooR9/Xp0hyB+IMY56jsH4fcgtIUx5xAeV8v3iRUWsxltdK7oKu0PhCK9ccJkCVCg==" />
          <button type="submit" class="dropdown-item dropdown-signout" data-ga-click="Header, sign out, icon:logout">
            Sign out
          </button>
    
    <div id="js-flash-container">
    
      <ul class="pagehead-actions">
    
  •     <div class="select-menu js-menu-container js-select-menu">
          <a href="/claytonbez/tcp-emit-server/subscription"
            class="btn btn-sm btn-with-count select-menu-button js-menu-target"
            role="button"
            aria-haspopup="true"
            aria-expanded="false"
            aria-label="Toggle repository notifications menu"
            data-ga-click="Repository, click Watch settings, action:blob#show">
            <span class="js-select-button">
                <svg class="octicon octicon-eye" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8.06 2C3 2 0 8 0 8s3 6 8.06 6C13 14 16 8 16 8s-3-6-7.94-6zM8 12c-2.2 0-4-1.78-4-4 0-2.2 1.8-4 4-4 2.22 0 4 1.8 4 4 0 2.22-1.78 4-4 4zm2-4c0 1.11-.89 2-2 2-1.11 0-2-.89-2-2 0-1.11.89-2 2-2 1.11 0 2 .89 2 2z"/></svg>
                Unwatch
            </span>
          </a>
          <a class="social-count js-social-count"
            href="/claytonbez/tcp-emit-server/watchers"
            aria-label="1 user is watching this repository">
            1
          </a>
    
        <div class="select-menu-modal-holder">
          <div class="select-menu-modal subscription-menu-modal js-menu-content">
            <div class="select-menu-header js-navigation-enable" tabindex="-1">
              <svg class="octicon octicon-x js-menu-close" role="img" aria-label="Close" viewBox="0 0 12 16" version="1.1" width="12" height="16"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"/></svg>
              <span class="select-menu-title">Notifications</span>
            </div>
    
              <div class="select-menu-list js-navigation-container" role="menu">
    
                <div class="select-menu-item js-navigation-item " role="menuitem" tabindex="0">
                  <svg class="octicon octicon-check select-menu-item-icon" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5L12 5z"/></svg>
                  <div class="select-menu-item-text">
                    <input type="radio" name="do" id="do_included" value="included" />
                    <span class="select-menu-item-heading">Not watching</span>
                    <span class="description">Be notified when participating or @mentioned.</span>
                    <span class="js-select-button-text hidden-select-button-text">
                      <svg class="octicon octicon-eye" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8.06 2C3 2 0 8 0 8s3 6 8.06 6C13 14 16 8 16 8s-3-6-7.94-6zM8 12c-2.2 0-4-1.78-4-4 0-2.2 1.8-4 4-4 2.22 0 4 1.8 4 4 0 2.22-1.78 4-4 4zm2-4c0 1.11-.89 2-2 2-1.11 0-2-.89-2-2 0-1.11.89-2 2-2 1.11 0 2 .89 2 2z"/></svg>
                      Watch
                    </span>
                  </div>
                </div>
    
                <div class="select-menu-item js-navigation-item selected" role="menuitem" tabindex="0">
                  <svg class="octicon octicon-check select-menu-item-icon" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5L12 5z"/></svg>
                  <div class="select-menu-item-text">
                    <input type="radio" name="do" id="do_subscribed" value="subscribed" checked="checked" />
                    <span class="select-menu-item-heading">Watching</span>
                    <span class="description">Be notified of all conversations.</span>
                    <span class="js-select-button-text hidden-select-button-text">
                      <svg class="octicon octicon-eye" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8.06 2C3 2 0 8 0 8s3 6 8.06 6C13 14 16 8 16 8s-3-6-7.94-6zM8 12c-2.2 0-4-1.78-4-4 0-2.2 1.8-4 4-4 2.22 0 4 1.8 4 4 0 2.22-1.78 4-4 4zm2-4c0 1.11-.89 2-2 2-1.11 0-2-.89-2-2 0-1.11.89-2 2-2 1.11 0 2 .89 2 2z"/></svg>
                        Unwatch
                    </span>
                  </div>
                </div>
    
                <div class="select-menu-item js-navigation-item " role="menuitem" tabindex="0">
                  <svg class="octicon octicon-check select-menu-item-icon" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5L12 5z"/></svg>
                  <div class="select-menu-item-text">
                    <input type="radio" name="do" id="do_ignore" value="ignore" />
                    <span class="select-menu-item-heading">Ignoring</span>
                    <span class="description">Never be notified.</span>
                    <span class="js-select-button-text hidden-select-button-text">
                      <svg class="octicon octicon-mute" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8 2.81v10.38c0 .67-.81 1-1.28.53L3 10H1c-.55 0-1-.45-1-1V7c0-.55.45-1 1-1h2l3.72-3.72C7.19 1.81 8 2.14 8 2.81zm7.53 3.22l-1.06-1.06-1.97 1.97-1.97-1.97-1.06 1.06L11.44 8 9.47 9.97l1.06 1.06 1.97-1.97 1.97 1.97 1.06-1.06L13.56 8l1.97-1.97z"/></svg>
                        Stop ignoring
                    </span>
                  </div>
                </div>
    
              </div>
    
            </div>
          </div>
        </div>
    
  • Unstar 0 Star 0
  • Fork 0
  •   <h1 class="public ">
    

    /tcp-emit-server

    </div>
    
    Code
    <span itemscope itemtype="http://schema.org/ListItem" itemprop="itemListElement">
      <a itemprop="url" data-hotkey="g i" class="js-selected-navigation-item reponav-item" data-selected-links="repo_issues repo_labels repo_milestones /claytonbez/tcp-emit-server/issues" href="/claytonbez/tcp-emit-server/issues">
        <svg class="octicon octicon-issue-opened" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"/></svg>
        <span itemprop="name">Issues</span>
        <span class="Counter">0</span>
        <meta itemprop="position" content="2">
    

    Pull requests 0
    <a data-hotkey="g b" class="js-selected-navigation-item reponav-item" data-selected-links="repo_projects new_repo_project repo_project /claytonbez/tcp-emit-server/projects" href="/claytonbez/tcp-emit-server/projects">
      <svg class="octicon octicon-project" viewBox="0 0 15 16" version="1.1" width="15" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 0 0-1 1v14a1 1 0 0 0 1 1h13a1 1 0 0 0 1-1V1a1 1 0 0 0-1-1z"/></svg>
      Projects
      <span class="Counter" >0</span>
    
    Wiki Insights Settings

    Permalink

    type="button" aria-label="Switch branches or tags" aria-expanded="false" aria-haspopup="true">
      <i>Branch:</i>
      <span class="js-select-button css-truncate-target">master</span>
    
    <div class="select-menu-modal">
      <div class="select-menu-header">
        <svg class="octicon octicon-x js-menu-close" role="img" aria-label="Close" viewBox="0 0 12 16" version="1.1" width="12" height="16"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"/></svg>
        <span class="select-menu-title">Switch branches/tags</span>
      </div>
    
      <div class="select-menu-filters">
        <div class="select-menu-text-filter">
          <input type="text" aria-label="Find or create a branch…" id="context-commitish-filter-field" class="form-control js-filterable-field js-navigation-enable" placeholder="Find or create a branch…">
        </div>
        <div class="select-menu-tabs">
          <ul>
            <li class="select-menu-tab">
              <a href="#" data-tab-filter="branches" data-filter-placeholder="Find or create a branch…" class="js-select-menu-tab" role="tab">Branches</a>
            </li>
            <li class="select-menu-tab">
              <a href="#" data-tab-filter="tags" data-filter-placeholder="Find a tag…" class="js-select-menu-tab" role="tab">Tags</a>
            </li>
          </ul>
        </div>
      </div>
    
      <div class="select-menu-list select-menu-tab-bucket js-select-menu-tab-bucket" data-tab-filter="branches" role="menu">
    
        <div data-filterable-for="context-commitish-filter-field" data-filterable-type="substring">
    
    
            <a class="select-menu-item js-navigation-item js-navigation-open selected"
               href="/claytonbez/tcp-emit-server/blob/master/README.md"
               data-name="master"
               data-skip-pjax="true"
               rel="nofollow">
              <svg class="octicon octicon-check select-menu-item-icon" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5L12 5z"/></svg>
              <span class="select-menu-item-text css-truncate-target js-select-menu-filter-text">
                master
              </span>
            </a>
        </div>
    
          <!-- '"` --><!-- </textarea></xmp> --></option></form><form class="js-create-branch select-menu-item select-menu-new-item-form js-navigation-item js-new-item-form" action="/claytonbez/tcp-emit-server/branches" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><input type="hidden" name="authenticity_token" value="Ba33cceaczVs62y57QqqUciPrQxaqe207xM8hNV3dyUQRtnfDdfw/BquvxPuBJbGzvPeVBLTU3on+KeFMOLHkA==" />
          <svg class="octicon octicon-git-branch select-menu-item-icon" viewBox="0 0 10 16" version="1.1" width="10" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M10 5c0-1.11-.89-2-2-2a1.993 1.993 0 0 0-1 3.72v.3c-.02.52-.23.98-.63 1.38-.4.4-.86.61-1.38.63-.83.02-1.48.16-2 .45V4.72a1.993 1.993 0 0 0-1-3.72C.88 1 0 1.89 0 3a2 2 0 0 0 1 1.72v6.56c-.59.35-1 .99-1 1.72 0 1.11.89 2 2 2 1.11 0 2-.89 2-2 0-.53-.2-1-.53-1.36.09-.06.48-.41.59-.47.25-.11.56-.17.94-.17 1.05-.05 1.95-.45 2.75-1.25S8.95 7.77 9 6.73h-.02C9.59 6.37 10 5.73 10 5zM2 1.8c.66 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2C1.35 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2zm0 12.41c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm6-8c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"/></svg>
            <div class="select-menu-item-text">
              <span class="select-menu-item-heading">Create branch: <span class="js-new-item-name"></span></span>
              <span class="description">from ‘master’</span>
            </div>
            <input type="hidden" name="name" id="name" class="js-new-item-value">
            <input type="hidden" name="branch" id="branch" value="master">
            <input type="hidden" name="path" id="path" value="README.md">
    
      <div class="select-menu-list select-menu-tab-bucket js-select-menu-tab-bucket" data-tab-filter="tags">
        <div data-filterable-for="context-commitish-filter-field" data-filterable-type="substring">
    
    
        </div>
    
        <div class="select-menu-no-results">Nothing to show</div>
      </div>
    
    </div>
    
    <div class="BtnGroup float-right">
      <a href="/claytonbez/tcp-emit-server/find/master"
            class="js-pjax-capture-input btn btn-sm BtnGroup-item"
            data-pjax
            data-hotkey="t">
        Find file
      </a>
      <clipboard-copy for="blob-path" class="btn btn-sm BtnGroup-item">
        Copy path
      </clipboard-copy>
    </div>
    <div id="blob-path" class="breadcrumb">
      <span class="repo-root js-repo-root"><span class="js-path-segment"><a data-pjax="true" href="/claytonbez/tcp-emit-server"><span>tcp-emit-server</span></a></span></span><span class="separator">/</span><strong class="final-path">README.md</strong>
    </div>
    
    17ec7ee Jul 1, 2018
    <div class="commit-tease-contributors">
      <button type="button" class="btn-link muted-link contributors-toggle" data-facebox="#blob_contributors_box">
        <strong>1</strong>
         contributor
      </button>
      
    </div>
    
    <div id="blob_contributors_box" style="display:none">
      <h2 class="facebox-header" data-facebox-id="facebox-header">Users who have contributed to this file</h2>
      <ul class="facebox-user-list" data-facebox-id="facebox-description">
          <li class="facebox-user-list-item">
            <a class="d-inline-block" data-hovercard-user-id="6775201" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/claytonbez"><img src="https://avatars1.githubusercontent.com/u/6775201?s=48&amp;v=4" width="24" height="24" alt="@claytonbez" /></a>
            <a data-hovercard-user-id="6775201" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/claytonbez">claytonbez</a>
          </li>
      </ul>
    </div>
    
    <div class="BtnGroup">
      <a id="raw-url" class="btn btn-sm BtnGroup-item" href="/claytonbez/tcp-emit-server/raw/master/README.md">Raw</a>
        <a class="btn btn-sm js-update-url-with-hash BtnGroup-item" data-hotkey="b" href="/claytonbez/tcp-emit-server/blame/master/README.md">Blame</a>
      <a rel="nofollow" class="btn btn-sm BtnGroup-item" href="/claytonbez/tcp-emit-server/commits/master/README.md">History</a>
    </div>
    
        <a class="btn-octicon tooltipped tooltipped-nw"
           href="https://desktop.github.com"
           aria-label="Open this file in GitHub Desktop"
           data-ga-click="Repository, open with desktop, type:windows">
            <svg class="octicon octicon-device-desktop" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M15 2H1c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h5.34c-.25.61-.86 1.39-2.34 2h8c-1.48-.61-2.09-1.39-2.34-2H15c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm0 9H1V3h14v8z"/></svg>
        </a>
    
          <!-- '"` --><!-- </textarea></xmp> --></option></form><form class="inline-form js-update-url-with-hash" action="/claytonbez/tcp-emit-server/edit/master/README.md" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><input type="hidden" name="authenticity_token" value="a0K+Jr0k7RTekyTmbyvuXdcGfWQF2koVUrLymI9UOjNEHYMkOGo8GUlCmdsd8lDRqw5CUguvu7jO3L0EAMZzDA==" />
            <button class="btn-octicon tooltipped tooltipped-nw" type="submit"
              aria-label="Edit this file" data-hotkey="e" data-disable-with>
              <svg class="octicon octicon-pencil" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M0 12v3h3l8-8-3-3-8 8zm3 2H1v-2h1v1h1v1zm10.3-9.3L12 6 9 3l1.3-1.3a.996.996 0 0 1 1.41 0l1.59 1.59c.39.39.39 1.02 0 1.41z"/></svg>
            </button>
    
    230 lines (202 sloc) 8.4 KB

    tcp-emit-server

    v0.0.3a ~ Some testing still required before I take it out of alpha.

    This module works in conjunction with tcp-emit-client.js

    Inspired by the ease of application of Socket.io. This is an event emitter based tcp server manager built using the net module native to NodeJS. It handles emit on all sockets, single sockets or rooms. Management of the connections are taken care of in the module.

    Extra Features

    Built into the server and client module is the ability to send and receive files using the .fileSend() method. This is a controlled buffer over TCP/IP read and write using only the 'fs' modules read and write streams.

    Installation

    npm install tcp-emit-server -save

    Getting Started

    Here is a quick server example.
    var tcpserver = require('tcp-emit-server');
    var server = new tcpserver('127.0.0.1',3000);
    

    server.on('connection',function(socket){

    <span class="pl-en">console</span>.<span class="pl-c1">log</span>(<span class="pl-s"><span class="pl-pds">`</span>Socket <span class="pl-s1"><span class="pl-pse">${</span><span class="pl-smi">socket</span>.<span class="pl-smi">ipaddress</span><span class="pl-pse">}</span></span>:<span class="pl-s1"><span class="pl-pse">${</span><span class="pl-smi">socket</span>.<span class="pl-smi">ipport</span><span class="pl-pse">}</span></span> connected<span class="pl-pds">`</span></span>);
    <span class="pl-c"><span class="pl-c">//</span>you can create any listener you like, ie. 'register'</span>
    <span class="pl-smi">socket</span>.<span class="pl-en">on</span>(<span class="pl-s"><span class="pl-pds">'</span>register<span class="pl-pds">'</span></span>,<span class="pl-k">function</span>(<span class="pl-smi">username</span>,<span class="pl-smi">password</span>){ 
    	<span class="pl-en">console</span>.<span class="pl-c1">log</span>(<span class="pl-s"><span class="pl-pds">`</span>Registering <span class="pl-s1"><span class="pl-pse">${</span>username<span class="pl-pse">}</span></span>,<span class="pl-s1"><span class="pl-pse">${</span>password<span class="pl-pse">}</span></span><span class="pl-pds">`</span></span>);
        <span class="pl-smi">socket</span>.<span class="pl-en">emit</span>(<span class="pl-s"><span class="pl-pds">'</span>register-done<span class="pl-pds">'</span></span>);
    });
    <span class="pl-c"><span class="pl-c">//</span>here is native events that emit on the socket object</span>
    <span class="pl-smi">socket</span>.<span class="pl-en">on</span>(<span class="pl-s"><span class="pl-pds">'</span>data<span class="pl-pds">'</span></span>,<span class="pl-k">function</span>(<span class="pl-smi">buffer</span>){
    	<span class="pl-k">var</span> data <span class="pl-k">=</span> <span class="pl-smi">buffer</span>.<span class="pl-c1">toString</span>();
    	<span class="pl-en">console</span>.<span class="pl-c1">log</span>(<span class="pl-s"><span class="pl-pds">`</span>RAW SOCKET DATA: <span class="pl-s1"><span class="pl-pse">${</span>data<span class="pl-pse">}</span></span><span class="pl-pds">`</span></span>);
    });
    <span class="pl-smi">socket</span>.<span class="pl-en">on</span>(<span class="pl-s"><span class="pl-pds">'</span>disconnect<span class="pl-pds">'</span></span>,<span class="pl-k">function</span>(){
    	<span class="pl-en">console</span>.<span class="pl-c1">log</span>(<span class="pl-s"><span class="pl-pds">`</span>Socket <span class="pl-s1"><span class="pl-pse">${</span><span class="pl-smi">socket</span>.<span class="pl-smi">ipaddress</span><span class="pl-pse">}</span></span>:<span class="pl-s1"><span class="pl-pse">${</span><span class="pl-smi">socket</span>.<span class="pl-smi">ipport</span><span class="pl-pse">}</span></span> DISCONNECTED<span class="pl-pds">`</span></span>);
    });
    <span class="pl-smi">socket</span>.<span class="pl-en">on</span>(<span class="pl-s"><span class="pl-pds">'</span>err<span class="pl-pds">'</span></span>,<span class="pl-k">function</span>(<span class="pl-smi">err</span>){
    	<span class="pl-en">console</span>.<span class="pl-c1">log</span>(err); 
        <span class="pl-c"><span class="pl-c">//</span>when sockets don't close properly, this event will be emitted along side the disconnect event.</span>
    });
    

    });

    Below is a tcp-emit-client sample to connect to the server code above.

    npm install tcp-emit-client

    var tcpclient = require('tcp-emit-client');
    var socket = new tcpclient('127.0.0.1',3000);
    

    socket.on('connect',function(){ console.log('connected to server'); socket.emit("register","myudername","mypassword"); }); socket.on('data',function(buffer){ //use this method is you purely want to read data received on the tcp socket. var data = buffer.toString(); console.log(</span>RAW SOCKET DATA: <span class="pl-s1"><span class="pl-pse">${</span>data<span class="pl-pse">}</span></span><span class="pl-pds">); }); socket.on('register-done',function(){ console.log("This client has been registered"); socket.close(); //closes the tcp connection to the server and destroyed all socket objects }); socket.on('disconnect',function(){ console.log('Disconnected From Server'); }); socket.on('reconnect',function(){ console.log('Reconnecting to Server'); }); socket.on('err',function(err){ console.log(err); });

    Basic Server Methods

    - Create TCP Server Object

    new tcpserver(server_ip_address,port_to_run_on);
    var tcpserver = require('tcp-emit-server');
    var server = new tcpserver('127.0.0.1',3000);

    - Connection Event

    serverObject.on('connect',function(){});
    var tcpserver = require('tcp-emit-server');
    var server = new tcpserver('127.0.0.1',3000);
    

    server.on('connection',function(socket){ //This event gets triggered each time a new socket is connected and is //where you will handle most of your server-client messaging });

    - Emit to All Sockets connected to serverObject

    serverObject.emit('yourEvent',dataObj,str,integer);
    var tcpserver = require('tcp-emit-server');
    var server = new tcpserver('127.0.0.1',3000);
    

    server.on('connection',function(socket){ socket.on('data',function(buffer){ var data = buffer.toString(); console.log(</span>RAW SOCKET DATA: <span class="pl-s1"><span class="pl-pse">${</span>data<span class="pl-pse">}</span></span><span class="pl-pds">); }); socket.on('disconnect',function(){ console.log(</span>Socket <span class="pl-s1"><span class="pl-pse">${</span><span class="pl-smi">socket</span>.<span class="pl-smi">ipaddress</span><span class="pl-pse">}</span></span>:<span class="pl-s1"><span class="pl-pse">${</span><span class="pl-smi">socket</span>.<span class="pl-smi">ipport</span><span class="pl-pse">}</span></span> DISCONNECTED<span class="pl-pds">); }); socket.on('err',function(err){ console.log(err); //when sockets don't close properly, this event will be emitted along side the disconnect event. }); });

    - SocketObject

    socket.on('yourEvent',function(data1,data2,data3){});

    Gets passed via the connection event and can only be used inside its scope.

    var tcpserver = require('tcp-emit-server');
    var server = new tcpserver('127.0.0.1',3000);
    

    server.on('connection',function(socket){ //The socket object itself is an event emitter and has certian native events that you can listen for. socket.on('message',function(stringMessage){ server.emit('broadcaseMessage',stringMessage); //Emitting on Server object sends to all sockets connected. Even the socket that emitted the 'message' }); });

    socket.emit('yourEvent',data1,data2,data3);

    Emitting on the socket object itself sends the event and data to the single socket instance only

    var tcpserver = require('tcp-emit-server');
    var server = new tcpserver('127.0.0.1',3000);
    

    server.on('connection',function(socket){ //The socket object itself is an event emitter and has certian native events that you can listen for. socket.on('message',function(stringMessage){
    server.emit('broadcaseMessage',stringMessage); //Emitting on Server object sends to all sockets connected. Even the socket that emitted the 'message' }); });

    Rooms
    socket.join('room');
    	- Adds the current Socket to a defined room
    socket.leave('room');
    	- Removes the current Socket from a defined room
    socket.emitIn('roomName','Data to Send');
    	- Sends a message to all sockets in the room except the originator
    socket.broadcasts('roomName','Data To SEND TO ALL');
    	- Sends a message to all sockets in the room including the originator
    

    You may also broadcast messages from the serverObject to a room

    server.broadcast('roomName',data1,data2,data3); 
    

    Any socket can be added to a room by calling this method. This enables you to emit data to a group of sockets. Here is an example of usage.

    var tcpserver = require('tcp-emit-server');
    var server = new tcpserver('127.0.0.1',3000);
    

    server.on('connection',function(socket){ //You must create the method of knowing when to add a socket to a group. //"Chat Rooms" are a great examples of grouping sockets. socket.on('join-my-room',function(roomName){ socket.join(roomName); //This socket is now part of a room }); socket.on('leave-my-room',function(roomName){ socket.leave(roomName); //This socket is now removed from the room }); socket.on('message-all',function(room,message){ socket.emitIn(room,message); //socketObj.emitIn(roomName,dataToSend,data2,data3); send to everyone in the room except the originator }); socket.on('message-alert',function(room,message){ socket.broadcast(room,message); //socketObj.broadcast(roomName,dataToSend,data2,data3); send to everyone in the room including the originator }); }); //serverObject.broadcast(roomName,dataToSend,data2,data3); sensd to everyone in the room

    File Transfer Methods
    socket.fileSend('path/to/file.txt');
    	- Emits on the 'file' event on the client side. Starts and manages transmission of files between server and client.
    	- Both modules uses the same method
    socket.on('getfile',function(filename){});
    	- Emits on the 'getfile' event on the client side. Starts and manages transmission of files between server and client.
    	- Both modules uses the same method
    

    Here is an Example of Server sending files to a client. Same methods are available for send and receive on the server and client.

    //SERVER SCRIPT
    var tcp = require('tcp-emit-server');
    var server = new tcp('127.0.0.1',3000);
    

    server.on('connection',function(socket){

    <span class="pl-smi">socket</span>.<span class="pl-en">on</span>(<span class="pl-s"><span class="pl-pds">'</span>myfileRequestEvent<span class="pl-pds">'</span></span>, <span class="pl-k">function</span> (<span class="pl-smi">filename</span>) {
        <span class="pl-en">console</span>.<span class="pl-c1">log</span>(<span class="pl-s"><span class="pl-pds">"</span>file requested:<span class="pl-pds">"</span></span>, filename);
        <span class="pl-smi">socket</span>.<span class="pl-en">sendFile</span>(<span class="pl-s"><span class="pl-pds">"</span>relative/path/to/file/<span class="pl-pds">"</span></span><span class="pl-k">+</span>filename);
    });
    

    });

    //CLIENT SCRIPT var tcpclient = require('tcp-emit-client'); var socket = new tcpclient('127.0.0.1',3000);

    socket.on('connect', function () { //Requests The File On Connection to Server socket.emit('myFileRequestEvent','sampleFile.txt'); }); socket.on('file', function (file) { //the object passed via the file event contains a file.filename and file.size property you can access. var fn = file.filename; var size = file.size; var f = fs.createWriteStream('relative/path/to/save/directory/' + fn); file.on('data', function (buffer) { //as data arrives for this file object, a buffer will be passed in on the 'data' event. f.write(buffer); }); file.on('end', function () { //when data has been console.log('File Received'); }); });

    Jump to Line

    Go
    </div>
    
    <a aria-label="Homepage" title="GitHub" class="footer-octicon" href="https://github.com">
      <svg height="24" class="octicon octicon-mark-github" viewBox="0 0 16 16" version="1.1" width="24" aria-hidden="true"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"/></svg>
    
    You can’t perform that action at this time.
    <script crossorigin="anonymous" integrity="sha512-LB1tzJRQ5uPC9BeR2Mb4TOIBPBxMXSM2p2+WgU7lLEdqAe7TptfwpDfDqfAnWlC2aw7FoJcKQxqDyjulVPpIbw==" type="application/javascript" src="https://assets-cdn.github.com/assets/frameworks-ad697dde9ac7f691157024c54b447026.js"></script>
    
    <script crossorigin="anonymous" async="async" integrity="sha512-Tqd1j3zgJYL8NSjEw4UYqRS4kQ09vPAu4KWouT3+gnnt5Mupx/Ps2ZM/CdF6oa1L0dw+vxRHaAkgkpcahIX40g==" type="application/javascript" src="https://assets-cdn.github.com/assets/github-e10f06304c6b9fd853406284acc0fe0a.js"></script>
    
    
    
    You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
    Press h to open a hovercard with more details.

    Keywords

    FAQs

    Package last updated on 01 Jul 2018

    Did you know?

    Socket

    Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

    Install

    Related posts

    SocketSocket SOC 2 Logo

    Product

    • Package Alerts
    • Integrations
    • Docs
    • Pricing
    • FAQ
    • Roadmap
    • Changelog

    Packages

    npm

    Stay in touch

    Get open source security insights delivered straight into your inbox.


    • Terms
    • Privacy
    • Security

    Made with ⚡️ by Socket Inc