Code Monkey home page Code Monkey logo

hp-socket-for-macos's Introduction

HP-Socket for macOS

项目介绍

由于平台限制某些机制某些机制会无法正常提供。

己知无法正常提供机制:

1、TCP协议中设置Keep live 时间:TCP_KEEPALIVETCP_KEEPINTVLTCP_KEEPCNT解决方法)。

2、对平台版本(macOS系统版本)有所要求,必需10.12之上的版本(包含)。

对平台版本的要求主要是其中组件RWLock.h中依赖shared_timed_mutex,而根据_LIBCPP_AVAILABILITY_SHARED_MUTEX定义对平台版本有所要求(若引入boost进行替代也可解决此问题)。

HP-Socket for macOS版本只是提供与其他平台上相同的回调接口,内部使用其他一些机制与组件替换相应不兼容的组件。

机制:

epoll => kqueue

部分ServerONESHOT=>DISPATCH

`DISPATCH`等同与epoll中的`edge-triggered (ET)`,在macOS中`ONESHOT`会从内核中删除,而对于大量数据交换就代表有大量删除与添加,而使用ET(DISPATCH)只会重置状态(ENABLE)使其无效。

组件:

MessagePipe.h

HP-Socket for macOS改自HP-Socket for linux

支持

  • TcpServer/Client
  • UdpServer/Client
  • TcpPackServer/Client
  • TcpAgent
  • TcpPackAgent
  • Pull
  • HttpClient/Server
  • ARQ-UdpServer/Client
  • SSL

文件目录介绍

目录名 描述
hpsocket hpsocket网络框架相关的所有文件
hpsocket\src hpsocket的源文件
hpsocket\ssl-cert 测试ssl的相关证书
hpsocket\test 一些简单的测试例子
hpsocket\CMakeLists.txt cmake的配置文件
hpsocket\4C hpsocket框架提供的类C接口

提供的例子中请注意依赖头文件与库路径。

CMakeLists.txt

include_directories(/opt/local/include)
link_directories(/opt/local/lib)

link_libraries(ssl iconv z crypto)
add_definitions(-D_NEED_HTTP -D_SSL_SUPPORT -D_NEED_SSL)

如何使用4C接口?

将4C文件夹下的文件放置src目录下,删除以下文件

HPSocket.cpp
HPSocket.h
HPSocket-SSL.cpp
HPSocket-SSL.h

并提供了一个官方使用4C接口的http例子test_server_4c

完全支持官方使用示例


相关依赖如何安装?

通过使用brew或MacPort;例子中使用的是MacPort。

具体安装了以下依赖:

openssl @1.1.1d、zlib

hp-socket-for-macos's People

Contributors

aisiok avatar bowmanchow avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.