/* Copyright © 2015 Gluzskiy Alexandr (sss) This file is part of Unknown Download Manager (UDM). UDM 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. UDM 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 UDM. If not, see . */ #include "client_session.h" #include #include client_session::client_session(QObject *parent, boost::asio::io_service *io_service) : QObject(parent), io_service_(*io_service), socket_(*io_service) { } tcp::socket& client_session::socket() { return socket_; } void client_session::client_connect(QString host, int port) { //TODO: settings for connection timeout boost::asio::ip::tcp::resolver r(io_service_); boost::asio::ip::tcp::endpoint ep; ep.port(port); ep.address(boost::asio::ip::address::from_string(host.toStdString())); socket_.async_connect(ep, boost::bind(&client_session::connect_handler, this, boost::asio::placeholders::error)); } void client_session::connect_handler(const boost::system::error_code &e) { BOOST_LOG_TRIVIAL(debug)<<__FILE__<<":"<<__LINE__<<"\t"<