FACT++  1.0
void ConnectionPowerSwitch::HandleRead ( const boost::system::error_code &  err,
size_t  bytes_received 
)
inlineprivate

Definition at line 124 of file temperature.cc.

References Error(), and str.

Referenced by StartReadReport().

125  {
126  // Do not schedule a new read if the connection failed.
127  if (bytes_received==0 || err)
128  {
129  if (err==ba::error::eof)
130  {
131  if (!fRdfData.empty())
132  ProcessAnswer();
133  return;
134  }
135 
136  // 107: Transport endpoint is not connected (bs::error_code(107, bs::system_category))
137  // 125: Operation canceled
138  if (err && err!=ba::error::eof && // Connection closed by remote host
139  err!=ba::error::basic_errors::not_connected && // Connection closed by remote host
140  err!=ba::error::basic_errors::operation_aborted) // Connection closed by us
141  {
142  ostringstream str;
143  str << "Reading from " << URL() << ": " << err.message() << " (" << err << ")";// << endl;
144  Error(str);
145  }
146  PostClose(err!=ba::error::basic_errors::operation_aborted);
147 
148  fRdfData = "";
149  return;
150  }
151 
152  fRdfData += string(fArray.data(), bytes_received);
153 
154  // Does the message contain a header?
155  const size_t p1 = fRdfData.find("\r\n\r\n");
156  if (p1!=string::npos)
157  {
158  // Does the answer also contain the body?
159  const size_t p2 = fRdfData.find("\r\n\r\n", p1+4);
160  if (p2!=string::npos)
161  ProcessAnswer();
162  }
163 
164  // Go on reading until the web-server closes the connection
165  StartReadReport();
166  }
void PostClose(bool restart=true)
Definition: Connection.cc:125
char str[80]
Definition: test_client.c:7
std::string URL() const
Definition: Connection.h:151
int Error(const std::string &str)
Definition: MessageImp.h:49
boost::array< char, 4096 > fArray
Definition: temperature.cc:47

+ Here is the call graph for this function:

+ Here is the caller graph for this function: