Skip to content

Commit

Permalink
Redifine acl::shared_stream for c++11 using.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengshuxin committed Sep 26, 2023
1 parent 3e782a5 commit fe9004f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib_acl_cpp/include/acl_cpp/stream/server_socket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ namespace acl {

class socket_stream;

#if __cplusplus >= 201103L
using shared_stream = std::shared_ptr<socket_stream>;
#endif

enum {
OPEN_FLAG_NONE = 0,
OPEN_FLAG_NONBLOCK = 1, // 非阻塞模式
OPEN_FLAG_REUSEPORT = (1 << 1), // 端口复用,要求 Linux3.0 以上
OPEN_FLAG_FASTOPEN = (1 << 2), // 是否启用 Fast open(实验阶段)
OPEN_FLAG_EXCLUSIVE = (1 << 3), // 是否禁止复用地址
OPEN_FLAG_MULTICAST_LOOP = (1 << 4), // 是否允许组播时接收回路包
OPEN_FLAG_NONE = 0,
OPEN_FLAG_NONBLOCK = 1, // 非阻塞模式
OPEN_FLAG_REUSEPORT = (1 << 1), // 端口复用,要求 Linux3.0 以上
OPEN_FLAG_FASTOPEN = (1 << 2), // 是否启用 Fast open(实验阶段)
OPEN_FLAG_EXCLUSIVE = (1 << 3), // 是否禁止复用地址
OPEN_FLAG_MULTICAST_LOOP = (1 << 4), // 是否允许组播时接收回路包
};

/**
Expand Down Expand Up @@ -110,7 +114,6 @@ class ACL_CPP_API server_socket : public noncopyable {

#if __cplusplus >= 201103L
// 使用 c++11 shared_ptr 方式获得客户端流对象, 更安全地使用流对象
using shared_stream = std::shared_ptr<socket_stream>;

shared_stream shared_accept(int timeout = -1, bool* etimed = NULL) {
shared_stream ss(accept(timeout, etimed));
Expand Down

0 comments on commit fe9004f

Please sign in to comment.