954,535 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

UNIX Socket read/write functions

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.

nanodano
Junior Poster in Training
78 posts since Feb 2005
Reputation Points: 36
Solved Threads: 2
 

>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.

John A
Vampirical Lurker
Team Colleague
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
 

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.

Ancient Dragon
Retired & Loving It
Team Colleague
30,050 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

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

vijayan121
Posting Virtuoso
1,606 posts since Dec 2006
Reputation Points: 1,159
Solved Threads: 287
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You