~nrtb-core/nrtb/alpha

« back to all changes in this revision

Viewing changes to cpp/common/sockets/base_socket.cpp

  • Committer: Rick Stovall
  • Date: 2013-11-16 21:09:50 UTC
  • mfrom: (15.1.16 ricks-sprint-003)
  • Revision ID: rick_stovall_fpstovall-20131116210950-riiyz7lv1njccv96
Merging sprint-003. some refactoring, a couple bug fixes, and the interthread communications modules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
541
541
  return sockaddr_to_str(myaddr);
542
542
};
543
543
 
544
 
 
545
544
tcp_server_socket_factory::tcp_server_socket_factory(
546
545
                const string & address, 
547
 
                const unsigned short int backlog,
548
 
                const int queue_size)
 
546
                const unsigned short int backlog)
549
547
{
550
548
  // does not attempt to set up the connection initially.
551
549
  _address = address;
552
550
  _backlog = backlog;
553
 
  pending.resize(queue_size);
554
551
};
555
552
 
556
553
tcp_server_socket_factory::~tcp_server_socket_factory()
561
558
  try { stop_listen(); } catch (...) {};
562
559
};
563
560
 
 
561
tcp_socket_p tcp_server_socket_factory::get_sock()
 
562
{
 
563
  tcp_socket_p returnme = std::move(pending.pop());
 
564
  return std::move(returnme);
 
565
};
 
566
 
 
567
 
564
568
void tcp_server_socket_factory::start_listen()
565
569
{
566
570
  // take no action if the listen thread is already running.
725
729
      if (good_connect)
726
730
      {
727
731
        tcp_socket_p storeme(new tcp_socket(new_conn));
728
 
        server->pending.push(storeme);
 
732
        server->pending.push(std::move(storeme));
729
733
      };
730
734
    }; // while go;
731
735
  }