Boost logo

Boost Users :

From: Jakub Stachowski (stachowski_at_[hidden])
Date: 2006-11-08 02:22:22


Ivan LAURETTE wrote:

> Darwin 8.8.0
> Boost 1.33.1
> gcc 4.0.1
>
> Hello,
>
> I want to establish a SMTP connection through a socket, then dialog with
> the server using a stream. I thought I could to it like this:
> //--------------------------------------------
> #include <boost/iostreams/stream.hpp>
> #include <boost/iostreams/device/file_descriptor.hpp>
>
> using namespace std;
> using namespace boost::iostreams;
>
> ...
> int theSocket = socket(AF_INET,SOCK_STREAM,0);
> connect(theSocket, ...);
>
> file_descriptor fdDevice(theSocket);
> stream_buffer<file_descriptor> fdstream(fdDevice);
> iostream os(&fdstream);
>
> string answer;
> getline(os, answer);
> cout << answer << endl;
> os << "HELO xxxxx" << endl;
> getline(os, answer);
> cout << answer << endl;
> os << "MAIL FROM: <xxx.xxx_at_xxx.xxx>" << endl;
> getline(os, answer);
> cout << answer << endl;
> ...
> //--------------------------------------------
> But nothing seems to be written nor readen to/from the socket except for
> the first getline. What am I doing wrong here ?

Try flushing the stream after each write.

>
> Thanks in advance for any help.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net