一个C++封装的网络库


其实就只是对网络底层的一个封装,将一些回调全部都已经封装好,直接指定相应的回调函数就可以对收到的数据包进行处理。 个人觉得该网络库比较方便的地方就是可以直接将所有自定义及C++标准库容器直接发送到服务端,而原始的C函数发送时连续存储的内存。 注意,该库使用C11编译,所以客户端必须支持C11,压缩包里面有demo。
资源截图
代码片段和文件信息
/*
  Copyright (c) 2014 Randolph Voorhies Shane Grant
  All rights reserved.

  Redistribution and use in source and binary forms with or without
  modification are permitted provided that the following conditions are met:
      * Redistributions of source code must retain the above copyright
        notice this list of conditions and the following disclaimer.
      * Redistributions in binary form must reproduce the above copyright
        notice this list of conditions and the following disclaimer in the
        documentation and/or other materials provided with the distribution.
      * Neither the name of cereal nor the
        names of its contributors may be used to endorse or promote products
        derived from this software without specific prior written permission.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS“ AND
  ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING BUT NOT LIMITED TO THE IMPLIED
  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES AND SHANE GRANT BE LIABLE FOR ANY
  DIRECT INDIRECT INCIDENTAL SPECIAL EXEMPLARY OR CONSEQUENTIAL DAMAGES
  (INCLUDING BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  LOSS OF USE DATA OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  ON ANY THEORY OF LIABILITY WHETHER IN CONTRACT STRICT LIABILITY OR TORT
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef _MSC_VER
#  pragma warning(push)
#  pragma warning(disable : 4244 4267)
#endif

#include 
#include 
#include 
#include 

#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include se_object.hpp>

#include 
#include 
#include 
#include 

//! Runs serialization to save data to an ostringstream
/*! Used to time how long it takes to save data to an ostringstream.
    Everything that happens within the save function will be timed including
    any set-up necessary to perform the serialization.

    @param data The data to save
    @param saveFunction A function taking in an ostringstream and the data and returning void
    @return The ostringstream and the time it took to save the data */
template 
std::chrono::nanoseconds
saveData( T const & data std::function saveFunction std::ostringstream & os )
{
  auto start = std::chrono::high_resolution_clock::now();
  saveFunction( os data );
  return std::chrono::duration_cast( std::chrono::high

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-07-29 18:04  libSocket
     目录           0  2015-07-29 18:05  libSocketinclude
     目录           0  2015-07-29 18:05  libSocketincludecereal-1.1.2
     文件         469  2015-06-09 02:13  libSocketincludecereal-1.1.2.gitignore
     文件        1212  2015-06-09 02:13  libSocketincludecereal-1.1.2.travis.yml
     文件        1158  2015-06-09 02:13  libSocketincludecereal-1.1.2CMakeLists.txt
     目录           0  2015-07-29 18:05  libSocketincludecereal-1.1.2doc
     文件       80164  2015-06-09 02:13  libSocketincludecereal-1.1.2docdoxygen.in
     文件        6115  2015-06-09 02:13  libSocketincludecereal-1.1.2docDoxygenLayout.xml
     文件        1139  2015-06-09 02:13  libSocketincludecereal-1.1.2docfooter.html
     文件        1847  2015-06-09 02:13  libSocketincludecereal-1.1.2docmainpage.dox
     目录           0  2015-07-29 18:05  libSocketincludecereal-1.1.2include
     目录           0  2015-07-29 18:05  libSocketincludecereal-1.1.2includecereal
     文件       18158  2015-07-17 19:58  libSocketincludecereal-1.1.2includecerealaccess.hpp
     目录           0  2015-07-29 18:05  libSocketincludecereal-1.1.2includecerealarchives
     文件        6034  2015-06-09 02:13  libSocketincludecereal-1.1.2includecerealarchivesadapters.hpp
     文件        6682  2015-06-09 02:13  libSocketincludecereal-1.1.2includecerealarchivesinary.hpp
     文件       39748  2015-06-09 02:13  libSocketincludecereal-1.1.2includecerealarchivesjson.hpp
     文件       10813  2015-06-09 02:13  libSocketincludecereal-1.1.2includecerealarchivesportable_binary.hpp
     文件       35871  2015-06-09 02:13  libSocketincludecereal-1.1.2includecerealarchivesxml.hpp
     文件       39966  2015-07-20 17:08  libSocketincludecereal-1.1.2includecerealcereal.hpp
     目录           0  2015-07-29 18:05  libSocketincludecereal-1.1.2includecerealdetails
     文件       13221  2015-07-17 19:58  libSocketincludecereal-1.1.2includecerealdetailshelpers.hpp
     文件       19156  2015-06-09 02:13  libSocketincludecereal-1.1.2includecerealdetailspolymorphic_impl.hpp
     文件        3720  2015-06-09 02:13  libSocketincludecereal-1.1.2includecerealdetailsstatic_object.hpp
     文件       91251  2015-07-17 19:58  libSocketincludecereal-1.1.2includecerealdetails raits.hpp
     文件        2931  2015-06-09 02:13  libSocketincludecereal-1.1.2includecerealdetailsutil.hpp
     目录           0  2015-07-29 18:05  libSocketincludecereal-1.1.2includecerealexternal
     文件        4035  2015-06-09 02:13  libSocketincludecereal-1.1.2includecerealexternalase64.hpp
     目录           0  2015-07-29 18:05  libSocketincludecereal-1.1.2includecerealexternal
apidjson
     文件       28679  2015-06-09 02:13  libSocketincludecereal-1.1.2includecerealexternal
apidjsondocument.h
............此处省略152个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)