Note: Goby version 1 (shown here) is now considered obsolete. Please use version 2 for new projects, and consider upgrading old projects.

Goby Underwater Autonomy Project  Series: 1.1, revision: 163, released on 2013-02-06 14:23:27 -0500
util/liblinebasedcomms/tcp_client.h
00001 // copyright 2009 t. schneider tes@mit.edu
00002 // 
00003 // this file is part of comms, a library for handling various communications.
00004 //
00005 // This program is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // This software is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this software.  If not, see <http://www.gnu.org/licenses/>.
00017 
00018 #ifndef TCPClientH
00019 #define TCPClientH
00020 
00021 #include "client_base.h"
00022 #include "goby/util/string.h"
00023 
00024 namespace goby
00025 {
00026     namespace util
00027     {
00029         class TCPClient : public LineBasedClient<boost::asio::ip::tcp::socket>
00030         {
00031           public:
00037             TCPClient(const std::string& server,
00038                       unsigned port,
00039                       const std::string& delimiter = "\r\n");
00040             
00041             boost::asio::ip::tcp::socket& socket() { return socket_; }
00042 
00044             std::string local_endpoint() { return goby::util::as<std::string>(socket_.local_endpoint()); }
00046             std::string remote_endpoint() { return goby::util::as<std::string>(socket_.remote_endpoint()); }
00047 
00048           private:
00049             bool start_specific();
00050 
00051         
00052           private:
00053             static std::map<std::string, TCPClient*> inst_;
00054             boost::asio::ip::tcp::socket socket_;
00055             std::string server_;
00056             std::string port_;
00057 
00058         }; 
00059     }
00060 }
00061 
00062 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends