1 /* -*- c++ -*- */ 2 /* 3 * Copyright 2013 Free Software Foundation, Inc. 4 * 5 * This file is part of GNU Radio 6 * 7 * GNU Radio is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 3, or (at your option) 10 * any later version. 11 * 12 * GNU Radio is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with GNU Radio; see the file COPYING. If not, write to 19 * the Free Software Foundation, Inc., 51 Franklin Street, 20 * Boston, MA 02110-1301, USA. 21 */ 22 23 #ifndef INCLUDED_TCP_CONNECTION_H 24 #define INCLUDED_TCP_CONNECTION_H 25 26 #include <pmt/pmt.h> 27 #include <boost/array.hpp> 28 #include <boost/asio.hpp> 29 #include <boost/shared_ptr.hpp> 30 31 namespace gr { 32 33 class basic_block; 34 35 namespace blocks { 36 37 class tcp_connection 38 { 39 private: 40 boost::asio::ip::tcp::socket d_socket; 41 std::vector<char> d_buf; 42 basic_block* d_block; 43 bool d_no_delay; 44 45 tcp_connection(boost::asio::io_service& io_service, 46 int MTU = 10000, 47 bool no_delay = false); 48 49 public: 50 typedef boost::shared_ptr<tcp_connection> sptr; 51 52 static sptr 53 make(boost::asio::io_service& io_service, int MTU = 10000, bool no_delay = false); 54 socket()55 boost::asio::ip::tcp::socket& socket() { return d_socket; }; 56 57 void start(gr::basic_block* block); 58 void send(pmt::pmt_t vector); 59 void handle_read(const boost::system::error_code& error, size_t bytes_transferred); handle_write(boost::shared_ptr<char[]> txbuf,const boost::system::error_code & error,size_t bytes_transferred)60 void handle_write(boost::shared_ptr<char[]> txbuf, 61 const boost::system::error_code& error, 62 size_t bytes_transferred) 63 { 64 } 65 }; 66 67 } /* namespace blocks */ 68 } /* namespace gr */ 69 70 #endif /* INCLUDED_TCP_CONNECTION_H */ 71