diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-02-20 23:37:47 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-02-20 23:37:47 +0000 |
| commit | 69c40685a528a13212ae37ee66b28faec40dcbbf (patch) | |
| tree | 0bd7a60cfa4cfe21732f648ed25299db79e7920a /src/lib/util.h | |
| parent | a4c6be44273c2a4599199c6da02ec7d0036d3de1 (diff) | |
| parent | dc08d2da6bf14fd469005ea3512992c66b041da9 (diff) | |
Merge branch 'master' of ssh://carlh.dnsalias.org/home/carl/git/dvdomatic
Diffstat (limited to 'src/lib/util.h')
| -rw-r--r-- | src/lib/util.h | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/src/lib/util.h b/src/lib/util.h index c4940a5d7..87735ea8e 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -194,39 +194,35 @@ extern std::string get_optional_string (std::multimap<std::string, std::string> * that are useful for DVD-o-matic. * * This class wraps some things that I could not work out how to do with boost; - * most notably, sync read/write calls with timeouts, and the ability to peek into - * data being read. + * most notably, sync read/write calls with timeouts. */ class Socket { public: - Socket (); + Socket (int timeout = 30); /** @return Our underlying socket */ boost::asio::ip::tcp::socket& socket () { return _socket; } - void connect (boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp> const & endpoint, int timeout); - void write (uint8_t const * data, int size, int timeout); + void connect (boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp> const & endpoint); + + void write (uint32_t n); + void write (uint8_t const * data, int size); - void read_definite_and_consume (uint8_t* data, int size, int timeout); - void read_indefinite (uint8_t* data, int size, int timeout); - void consume (int amount); + void read (uint8_t* data, int size); + uint32_t read_uint32 (); private: void check (); - int read (uint8_t* data, int size, int timeout); Socket (Socket const &); boost::asio::io_service _io_service; boost::asio::deadline_timer _deadline; boost::asio::ip::tcp::socket _socket; - /** a buffer for small reads */ - uint8_t _buffer[1024]; - /** amount of valid data in the buffer */ - int _buffer_data; + int _timeout; }; /** @class AudioBuffers |
