client_socket.h
Go to the documentation of this file.
1 /*
2  * @brief client_socket encapsulates connecting, closing and setting socket options
3  * for tcp client sockets using boost::asio::ip::tcp::socket and boost::asio::io_service.
4  *
5  * Copyright (C) 2019 Ing.-Buero Dr. Michael Lehning, Hildesheim
6  * Copyright (C) 2019 SICK AG, Waldkirch
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  * All rights reserved.
21  *
22  * Redistribution and use in source and binary forms, with or without
23  * modification, are permitted provided that the following conditions are met:
24  *
25  * * Redistributions of source code must retain the above copyright
26  * notice, this list of conditions and the following disclaimer.
27  * * Redistributions in binary form must reproduce the above copyright
28  * notice, this list of conditions and the following disclaimer in the
29  * documentation and/or other materials provided with the distribution.
30  * * Neither the name of SICK AG nor the names of its
31  * contributors may be used to endorse or promote products derived from
32  * this software without specific prior written permission
33  * * Neither the name of Ing.-Buero Dr. Michael Lehning nor the names of its
34  * contributors may be used to endorse or promote products derived from
35  * this software without specific prior written permission
36  *
37  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
38  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
40  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
41  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
42  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
43  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
44  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
45  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
47  * POSSIBILITY OF SUCH DAMAGE.
48  *
49  * Authors:
50  * Michael Lehning <michael.lehning@lehning.de>
51  *
52  * Copyright 2019 SICK AG
53  * Copyright 2019 Ing.-Buero Dr. Michael Lehning
54  *
55  */
56 #ifndef __SIM_LOC_CLIENT_SOCKET_H_INCLUDED
57 #define __SIM_LOC_CLIENT_SOCKET_H_INCLUDED
58 
59 #include <boost/asio/buffer.hpp>
60 #include <boost/asio/io_service.hpp>
61 #include <boost/asio/ip/tcp.hpp>
62 #include <boost/asio/read.hpp>
63 #include <boost/asio/write.hpp>
64 
65 namespace sick_scan
66 {
72  {
73  public:
74 
79  ClientSocket(boost::asio::io_service & io_service);
80 
84  virtual ~ClientSocket();
85 
93  virtual bool connect(boost::asio::io_service & io_service, const std::string & server_adress, int tcp_port);
94 
101  virtual bool close(bool force_shutdown = false);
102 
107  virtual boost::asio::ip::tcp::socket & socket(void) { return m_tcp_socket; }
108 
109  protected:
110 
111  boost::asio::ip::tcp::socket m_tcp_socket;
112 
113  }; // class ClientSocket
114 
115 } // namespace sick_scan
116 #endif // __SIM_LOC_CLIENT_SOCKET_H_INCLUDED
sick_scan::ClientSocket::~ClientSocket
virtual ~ClientSocket()
Definition: client_socket.cpp:71
sick_scan::ClientSocket::socket
virtual boost::asio::ip::tcp::socket & socket(void)
Definition: client_socket.h:107
sick_scan::ClientSocket::m_tcp_socket
boost::asio::ip::tcp::socket m_tcp_socket
tcp client socket implementation
Definition: client_socket.h:111
sick_scan
Definition: abstract_parser.cpp:50
sick_scan::ClientSocket::ClientSocket
ClientSocket(boost::asio::io_service &io_service)
Definition: client_socket.cpp:64
sick_scan::ClientSocket
Definition: client_socket.h:71
sick_scan::ClientSocket::close
virtual bool close(bool force_shutdown=false)
Definition: client_socket.cpp:146
sick_scan::ClientSocket::connect
virtual bool connect(boost::asio::io_service &io_service, const std::string &server_adress, int tcp_port)
Definition: client_socket.cpp:83


sick_scan
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Thu Sep 8 2022 02:30:19