[prev in list] [next in list] [prev in thread] [next in thread]
List: boost-users
Subject: Re: [Boost-users] Socket and iostream
From: Jakub Stachowski <stachowski () hypair ! net>
Date: 2006-11-08 7:22:22
Message-ID: eis0k3$uf9$1 () sea ! gmane ! org
[Download RAW message or body]
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@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.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic