The intention of netstreams is to simplify object-oriented network programming in C++. It uses a socket class, which encapsulates the BSD and Windows Socket APIs. This socket class could be used by itself, but when using objects, it's much easier to rely on the higher level, iostream compatible classes. This way, netstream users can define a operator>> and/or a operator<< method that takes an istream or ostream object, respectively, and another object, and have the underlying netstream buffer take care of all the buffering required for network programming. (These methods could also be used for standard I/O, File I/O, or any other iostream compatible I/O).

The Socket class is the heart of netstreams. Eventually, I hope to have it support most UNIX platforms (including Linux), Windows, and Mac OS X. I also hope to support IPv6. I think this may require breaking the Socket class into more than one class.

The rest of the classes, basically encapsulate the iostream classes in C++. The net_streambuf class extends the streambuf. It overrides the underflow and overflow methods of streambuf and uses a member Socket to handle those conditions. This class handles the these conditions by containing internal buffers that buffer the data between the object and the socket.

The other main classes are tcp_stream, udp_stream, and raw_stream. These are the highest level classes that a netstream user deals with for sending and receiving objects.

Example:

//create a stream
tcp_stream stream( "www.ibm.com", 80 );

//create an object for a request and a response
HttpRequest request( "GET / HTTP/1.0" );
HttpResponse response;

//send object
stream << request << endl;

//receive response
stream >> response;


SourceForge Logo