*/
-#include "dcpomatic_socket.h"
+
#include "compose.hpp"
-#include "exceptions.h"
#include "dcpomatic_assert.h"
+#include "dcpomatic_socket.h"
+#include "exceptions.h"
#include <boost/bind/bind.hpp>
#include <boost/lambda/lambda.hpp>
#include <iostream>
#include "i18n.h"
+
using std::shared_ptr;
using std::weak_ptr;
+
/** @param timeout Timeout in seconds */
Socket::Socket (int timeout)
: _deadline (_io_service)
_deadline.async_wait (boost::bind (&Socket::check, this));
}
+
/** Blocking connect.
* @param endpoint End-point to connect to.
*/
}
}
+
/** Blocking write.
* @param data Buffer to write.
* @param size Number of bytes to write.
}
}
+
void
Socket::write (uint32_t v)
{
write (reinterpret_cast<uint8_t*> (&v), 4);
}
+
/** Blocking read.
* @param data Buffer to read to.
* @param size Number of bytes to read.
}
}
+
uint32_t
Socket::read_uint32 ()
{
_read_digester.reset (new Digester());
}
+
void
Socket::start_write_digest ()
{
bool
Socket::ReadDigestScope::check ()
{
- shared_ptr<Socket> sp = _socket.lock ();
+ auto sp = _socket.lock ();
if (!sp) {
return false;
}
Socket::WriteDigestScope::~WriteDigestScope ()
{
- shared_ptr<Socket> sp = _socket.lock ();
+ auto sp = _socket.lock ();
if (sp) {
try {
sp->finish_write_digest ();
return memcmp(ref, actual, size) == 0;
}
+
void
Socket::finish_write_digest ()
{