Is there any way to read or write to a socket besides using the read() and write() functions. Is there any way to treat it like a stream and use the insertion/extraction operators (<< and >>)? The reason I ask is because with read I have to put an arbitrary size on the message to be read, but that can vary.

>Is there any way to read or write to a socket besides using the read() and write() functions.
http://www.hmug.org/man/2/send.php
http://www.hmug.org/man/2/recv.php

>Is there any way to treat it like a stream and use the insertion/extraction operators (<< and >>)?
You'll need a C++ wrapper library. I don't know any off the top of my head.

Microsoft MFC has a c++ socket classes, but I hear it isn't very well liked. You might check boost libraries, it probably has something.

socket++ is a library that i have used. it works resonably well. it has a distinct c++ feel about it;
sockets in the library have the same interface as the streams in the iostream library. here is the link:
http://www.linuxhacker.at/socketxx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.