publishTimefunction is straightforward:
whileloop for writing bytes is a bit more important now that we are networking: we are more likely to need to write multiple times.
write's return value could very well be less than what was supplied by the third argument. For example, you may try to publish the contents of a 62GB movie and be told that only 4MB went through.
FILE *) or C++ streams (e.g. the
iostreamclass hierarchy) to layer over data buffers and manage the
whileloop around exposed
writecalls for us.
socket++—that provides precisely this.
socket++provides iostream subclasses that respond to
endl, and so forth, just as
cout, and file streams do.
iosockstreamthat itself layers over the client socket.
sockbufclass takes ownership of the socket and closes it when its destructor is called.
myth-busterand Assignment 5's
aggregate—where multithreading can signiﬁcantly improve the performance of networked applications.
acceptreturns a socket descriptor, spawn a child thread—or reuse an existing one within a
ThreadPool—to get any intense, time consuming computation oﬀ of the main thread. The child thread can make use of a second processor or a second core, and the main thread can quickly move on to its next
ThreadPool(you're implementing one for assign5) to get the computation oﬀ the main thread asap.
createClientSocket. For now, view it as a built-in that sets up a bidirectional pipe between a client and a server running on the speciﬁed host (e.g.
myth64) and bound to the speciﬁed port number (e.g. 12345).