After accepting a tcp connection the server must receive the data via the recv() system call. This system call takes in a char buffer and its size and only fills the buffer up to the provided size. This is a perfect fit for a stream abstraction so that when we parse the request we don't have to worry about the low level details of buffer size, incomplete messages etc.
Proposal to prototype Socket_Stream implementations that would continually call the recv() function with a fixed sized buffer and dump the contents into a stream. We could use std::stringstream for this or roll our own stream implementation.
Create a Socket_Stream class that takes in a bound socket as a construction parameter
The interface should mostly mimic the std::iostream interface.
behind the scenes the Socket_Stream should use a fixed buffer and some sort of dynamic buffer as well. When a call is made to read we will fill the fixed buffer with the recv() call and then copy the contents into the dynamic buffer.
Possible dynamic buffer solutions std::string, or std::stringstream. Or roll our own?
Use select() or Poll() to determine if the stream is readable?? Set a timeout value?
After accepting a tcp connection the server must receive the data via the
recv()
system call. This system call takes in a char buffer and its size and only fills the buffer up to the provided size. This is a perfect fit for a stream abstraction so that when we parse the request we don't have to worry about the low level details of buffer size, incomplete messages etc.Proposal to prototype Socket_Stream implementations that would continually call the
recv()
function with a fixed sized buffer and dump the contents into a stream. We could use std::stringstream for this or roll our own stream implementation.