X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fdcpomatic_socket.cc;h=ca910bb79aaa3fe80dedbc979d56df853c72e5f9;hp=d575e323027a4e77ed14afa9802d8ae1e82c657f;hb=5eb8b5c3a1566aef638e9d9df03b88d320735092;hpb=27867be66579551018c926ed3339624e463c1b08 diff --git a/src/lib/dcpomatic_socket.cc b/src/lib/dcpomatic_socket.cc index d575e3230..ca910bb79 100644 --- a/src/lib/dcpomatic_socket.cc +++ b/src/lib/dcpomatic_socket.cc @@ -1,19 +1,20 @@ /* Copyright (C) 2012-2015 Carl Hetherington - This program is free software; you can redistribute it and/or modify + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + DCP-o-matic is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with DCP-o-matic. If not, see . */ @@ -22,9 +23,11 @@ #include "exceptions.h" #include #include +#include #include "i18n.h" +/** @param timeout Timeout in seconds */ Socket::Socket (int timeout) : _deadline (_io_service) , _socket (_io_service) @@ -78,7 +81,7 @@ Socket::write (uint8_t const * data, int size) boost::system::error_code ec = boost::asio::error::would_block; boost::asio::async_write (_socket, boost::asio::buffer (data, size), boost::lambda::var(ec) = boost::lambda::_1); - + do { _io_service.run_one (); } while (ec == boost::asio::error::would_block); @@ -110,7 +113,7 @@ Socket::read (uint8_t* data, int size) do { _io_service.run_one (); } while (ec == boost::asio::error::would_block); - + if (ec) { throw NetworkError (String::compose (_("error during async_read (%1)"), ec.value ())); } @@ -123,4 +126,3 @@ Socket::read_uint32 () read (reinterpret_cast (&v), 4); return ntohl (v); } -