prev UP NEXT C++ socket classes for OS/2

9.1: iosockstreams

9.1.1: isockstream Class

Since isockstream is publicly derived from istream, most of the public functions of istream are also available in isockstream.

isockstream redefines rdbuf() defined in its virtual base class ios. Since, ios::rdbuf() is not virtual, care must be taken to call the correct rdbuf() through a reference or a pointer to an object of class isockstream.

In what follows,

isockstream is(sbp)
Constructs an isockstream object is with *sbp as its sockbuf.
sbp = is.rdbuf()
returns a pointer to the sockbuf of the isockstream object is.
isockstream::operator -> ()
returns a pointer to the isockstream's sockbuf so that the user can use isockstream object as a sockbuf object.

    is->connect (sa); // same as is.rdbuf()->connect (sa);

9.1.2: osockstream Class

Since osockstream is publicly derived from ostream, most of the public functions of ostream are also available in osockstream.

osockstream redefines rdbuf() defined in its virtual base class ios. Since, ios::rdbuf() is not virtual, care must be taken to call the correct rdbuf() through a reference or a pointer to an object of class osockstream.

In what follows,

osockstream os(sbp)
Constructs an osockstream object os with *sbp as its sockbuf.
sbp = os.rdbuf()
returns a pointer to the sockbuf of the osockstream object os.
osockstream::operator -> ()
returns a pointer to the osockstream's sockbuf so that the user can use osockstream object as a sockbuf object.

    os->connect (sa); // same as os.rdbuf()->connect (sa);

9.1.3: iosockstream Class

Since iosockstream is publicly derived from iostream, most of the public functions of iostream are also available in iosockstream.

iosockstream redefines rdbuf() defined in its virtual base class ios. Since, ios::rdbuf() is not virtual, care must be taken to call the correct rdbuf() through a reference or a pointer to an object of class iosockstream.

In what follows,

iosockstream io(sbp)
Constructs an iosockstream object io with *sbp as its sockbuf.
sbp = io.rdbuf()
returns a pointer to the sockbuf of the iosockstream object io.
iosockstream::operator -> ()
returns a pointer to the iosockstream's sockbuf so that the user can use iosockstream object as a sockbuf object.

    io->connect (sa); // same as io.rdbuf()->connect (sa);