bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

synchronized reading and writing


From: Chad Pettit
Subject: synchronized reading and writing
Date: Tue, 22 Oct 2002 14:55:35 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826

Using TCPSession how does synchronized reading and writing work.

I have something like this:

void Connection::runTransmitter()
{
   char line[200];
   std::iostream *connection = tcp();
   connection->write(_message.c_str(), _message.length());

   if (isPending(Socket::pendingInput))
*connection >> line; std::cerr << "Transmit: " << line << std::endl;
}

void Connection::runReceiver()
{ char line[200];
   std::iostream* connection = tcp();

   if (isPending(Socket::pendingInput))
       *connection >> line;
std::cerr << "Receive: " << line << std::endl; *connection << "message successfully received"; }

It hangs at the isPending function on the Receiver side. If I put in a endStream() call on the transmitter side, the receiver gets the message, but the tranmitter then hangs on its isPending. The endStream function ends the socket as well as the stream. I don't believe this is correct because I eventually want the communication to be ongoing between the receiver and transmitter.

Any help would be greatly appreciated.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]