Lecture #19 - Sockets-based Communication

Web Resources:

CppReference.com, CPlusPlus.com, C++ TechLinks
Going Native 2013 - many experts
Herb Sutter's Blog, Herb Sutter on C++11, Herb Sutter keynote - Going Native 2012
Scott Meyer's Blog, S.M. on thread suspension, S.M.: C++11 Sampler
Stroustrup's Home Page, Code Project, Boost Library

Content:

This lecture covers Sockets and Threads.
  1. Syllabus
    Describes topics to be covered, reading material for you to digest before coming to class, and due dates for the assigned projects.
  2. Projects:

    Project #3, Project3HelpS17 Code Publisher Samples
    Code Publisher - publishing source code files as web pages.

    Project #4, Project4HelpS17
    Remote Code Publisher
  3. Win32 Sockets

    Win32 Sockets Presentation, Windows Sockets Error Codes

    C++ Sockets, C++ StringServer
    This is the recommended source for sockets starter code.

    Message Passing Communication
    Discusses a proposed structure for message-passing communication for both Sockets and WCF.

    Tasks and ThreadPool
    Listeners for High load servers should use threadpool to run client handlers.

    HTTP style message-passing with File Transfer
    Demonstrates how to process HTTP style messages and send files. Has an HttpMessage class. Some of the server message handling could be better organized and made simpler.

    C++/CLI WPF application
    Illustrates how to build a GUI using C++/CLI. Uses a mock channel to show how to organize threading. This is important because managed code (C++/CLI and C#) must use .Net threads, but our channels all use C++11 threads. This demo shows how to do that.

    Beej's Guide to Network Programming (HTML pages), Beej's Guide to Network Programming (PDF document)
    Winsock Programmer's FAQ - out of date, but still useful

    Chalk Talk - File Transfer

    • Server structure - single queue
    • Sending file blocks
  4. C++11 - new features

    Herb Sutter's excellent and brief overview from his Blog

    C++11 concurrency
    Threads, locks, condition variables, async, futures, promises, packaged_tasks, and atomics

    C++11 BlockingQueue
    Uses condition variable and mutex to build a queue that blocks deQers when empty.

    Str strings
    Demonstrates move constructor and move assignment.

    Component Reference Counting
    Demonstrates variadic templates and functions.

    Symbol Table
    Illustrates how using aliases are a great design tool. Also demonstrates range-based for loops.

    Chrono Timer
    Uses Chrono library to build a high resolution timer precise to about 100 nanoseconds.

    Callable Objects
    Demonstrates lambdas and compares them to function pointers and functors.

    Singleton
    Uses atomic.

    Uniform Initialization
    Illustrates use of uniform initialization for user defined types and STL containers.

  5. Thinking about Software Design:

    Software Design
    Broad survey of ideas with examples
    Design Presentation
    Summarizes design issues for modules and classes.
    Design Guidelines
    Design rules and idioms that transcend Object Oriented Design.

    Design Summary

CST strip