No-op; fix GPL address and use the explicit-program-name version.
[dcpomatic.git] / src / lib / dcpomatic_socket.cc
index bc8f596a7fefbf30c043cbc80b6647ac50384137..fa06918d420ce6fbc696d5c177f2ef2a2b52e1b8 100644 (file)
@@ -1,19 +1,20 @@
 /*
     Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
 
-    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 <http://www.gnu.org/licenses/>.
 
 */
 
 #include "exceptions.h"
 #include <boost/bind.hpp>
 #include <boost/lambda/lambda.hpp>
+#include <iostream>
 
 #include "i18n.h"
 
 Socket::Socket (int timeout)
        : _deadline (_io_service)
        , _socket (_io_service)
-       , _acceptor (0)
        , _timeout (timeout)
 {
        _deadline.expires_at (boost::posix_time::pos_infin);
        check ();
 }
 
-Socket::~Socket ()
-{
-       delete _acceptor;
-}
-
 void
 Socket::check ()
 {
        if (_deadline.expires_at() <= boost::asio::deadline_timer::traits_type::now ()) {
-               if (_acceptor) {
-                       _acceptor->cancel ();
-               } else {
-                       _socket.close ();
-               }
+               _socket.close ();
                _deadline.expires_at (boost::posix_time::pos_infin);
        }
 
@@ -77,26 +69,6 @@ Socket::connect (boost::asio::ip::tcp::endpoint endpoint)
        }
 }
 
-void
-Socket::accept (int port)
-{
-       _acceptor = new boost::asio::ip::tcp::acceptor (_io_service, boost::asio::ip::tcp::endpoint (boost::asio::ip::tcp::v4(), port));
-       
-       _deadline.expires_from_now (boost::posix_time::seconds (_timeout));
-       boost::system::error_code ec = boost::asio::error::would_block;
-       _acceptor->async_accept (_socket, boost::lambda::var(ec) = boost::lambda::_1);
-       do {
-               _io_service.run_one ();
-       } while (ec == boost::asio::error::would_block);
-
-       delete _acceptor;
-       _acceptor = 0;
-       
-       if (ec) {
-               throw NetworkError (String::compose (_("error during async_accept (%1)"), ec.value ()));
-       }
-}
-
 /** Blocking write.
  *  @param data Buffer to write.
  *  @param size Number of bytes to write.
@@ -108,7 +80,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);
@@ -140,7 +112,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 ()));
        }
@@ -153,4 +125,3 @@ Socket::read_uint32 ()
        read (reinterpret_cast<uint8_t *> (&v), 4);
        return ntohl (v);
 }
-