/usr/include/claw/impl/osocket_stream.tpp is in libclaw-net-dev 1.7.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | /*
CLAW - a C++ Library Absolutely Wonderful
CLAW is a free library without any particular aim but being useful to
anyone.
Copyright (C) 2005-2011 Julien Jorge
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
contact: julien.jorge@gamned.org
*/
/**
* \file osocket_stream.tpp
* \brief Implementation of the claw::net::basic_osocket_stream class.
* \author Julien Jorge
*/
/*----------------------------------------------------------------------------*/
/**
* \brief Constructor.
*/
template<typename CharT, typename Traits>
claw::net::basic_osocket_stream<CharT, Traits>::basic_osocket_stream()
: super(&m_buffer)
{
} // basic_osocket_stream::basic_osocket_stream()
/*----------------------------------------------------------------------------*/
/**
* \brief Constructor.
* \param address The address to which we will connect.
* \param port The port number to use for the connection.
*/
template<typename CharT, typename Traits>
claw::net::basic_osocket_stream<CharT, Traits>::basic_osocket_stream
( const std::string& address, int port )
: super(&m_buffer)
{
open(address, port);
} // basic_osocket_stream::basic_osocket_stream()
/*----------------------------------------------------------------------------*/
/**
* \brief Destructor.
*/
template<typename CharT, typename Traits>
claw::net::basic_osocket_stream<CharT, Traits>::~basic_osocket_stream()
{
// nothing to do
} // basic_osocket_stream::~basic_osocket_stream()
/*----------------------------------------------------------------------------*/
/**
* \brief Get the output buffer.
*/
template<typename CharT, typename Traits>
typename claw::net::basic_osocket_stream<CharT, Traits>::buffer_type*
claw::net::basic_osocket_stream<CharT, Traits>::rdbuf() const
{
return const_cast<buffer_type*>(&m_buffer);
} // basic_osocket_stream::rdbuf()
/*----------------------------------------------------------------------------*/
/**
* \brief Tell if the stream is open.
*/
template<typename CharT, typename Traits>
bool claw::net::basic_osocket_stream<CharT, Traits>::is_open() const
{
return m_buffer.is_open();
} // basic_osocket_stream::()
/*----------------------------------------------------------------------------*/
/**
* \brief Connect the socket to an address.
* \param address The address to which we will connect.
* \param port The port number to use for the connection.
*/
template<typename CharT, typename Traits>
void claw::net::basic_osocket_stream<CharT, Traits>::open
( const std::string& address, int port )
{
if ( !m_buffer.open(address, port) )
this->setstate(std::ios_base::failbit);
else
this->clear();
} // basic_osocket_stream::open()
/*----------------------------------------------------------------------------*/
/**
* \brief Link the socket to a file descriptor.
* \param fd The file descriptor.
* \remark This method should be only called by claw::net::socket_server.
*/
template<typename CharT, typename Traits>
void claw::net::basic_osocket_stream<CharT, Traits>::open( int fd )
{
if ( !m_buffer.open(fd) )
this->setstate(std::ios_base::failbit);
else
this->clear();
} // basic_osocket_stream::open()
/*----------------------------------------------------------------------------*/
/**
* \brief Close the connection.
*/
template<typename CharT, typename Traits>
void claw::net::basic_osocket_stream<CharT, Traits>::close()
{
if ( !m_buffer.close() )
this->setstate(std::ios_base::failbit);
} // basic_osocket_stream::close()
|