acl/lib_acl_cpp/include/acl_cpp/stream/socket_stream.hpp

240 lines
6.0 KiB
C++
Raw Normal View History

2014-11-19 00:25:21 +08:00
#pragma once
#include "acl_cpp/acl_cpp_define.hpp"
#if defined(_WIN32) || defined(_WIN64)
2014-11-19 00:25:21 +08:00
#include <WinSock2.h>
#endif
#include "acl_cpp/stream/istream.hpp"
#include "acl_cpp/stream/ostream.hpp"
struct ACL_VSTREAM;
namespace acl {
class ACL_CPP_API socket_stream
: public istream
, public ostream
{
public:
socket_stream();
virtual ~socket_stream();
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD>ִ򿪵<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param fd <EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD>
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
*/
#if defined(_WIN32) || defined(_WIN64)
2014-11-19 00:25:21 +08:00
bool open(SOCKET fd);
#else
bool open(int fd);
#endif
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ACL_VSTREAM <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param vstream {ACL_VSTREAM*}
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
*/
bool open(ACL_VSTREAM* vstream);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD>̷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param addr {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽ӿڷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>UNIXƽ̨),
* <EFBFBD><EFBFBD><EFBFBD>׽ӵ<EFBFBD>ַ<EFBFBD><EFBFBD>/tmp/test.sock; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>TCP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>ʽΪ:
* [${local_ip}@]${remote_addr}, <EFBFBD><EFBFBD>: 60.28.250.199@www.sina.com:80,
* <EFBFBD><EFBFBD>˼<EFBFBD>ǰ󶨱<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַΪ: 60.28.250.199, Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.sina.com <EFBFBD><EFBFBD> 80,
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>OS<EFBFBD>Զ<EFBFBD><EFBFBD>󶨱<EFBFBD><EFBFBD><EFBFBD> IP <EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>дΪ<EFBFBD><EFBFBD>www.sina.com:80
* @param conn_timeout {int} <EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>ʱʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
* @param rw_timeout {int} <EFBFBD><EFBFBD>д<EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
*/
bool open(const char* addr, int conn_timeout, int rw_timeout);
/**
* <EFBFBD>󶨱<EFBFBD><EFBFBD><EFBFBD> UDP <EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> UDP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param addr {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>ip:port
* @param rw_timeout {int} <EFBFBD><EFBFBD>д<EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
*/
bool bind_udp(const char* addr, int rw_timeout = 0);
2017-04-07 20:13:08 +08:00
/**
* <EFBFBD>ر<EFBFBD><EFBFBD>׽ӿڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {bool}
*/
bool shutdown_read(void);
/**
* <EFBFBD>ر<EFBFBD><EFBFBD>׽ӿ<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {bool}
*/
bool shutdown_write(void);
/**
* <EFBFBD>ر<EFBFBD><EFBFBD>׽ӿڶ<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {bool}
*/
bool shutdown_readwrite(void);
2014-11-19 00:25:21 +08:00
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӿ<EFBFBD><EFBFBD><EFBFBD>
* @return {ACL_SOCKET} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򷵻<EFBFBD> - 1(UNIX ƽ̨)
* <EFBFBD><EFBFBD> INVALID_SOCKET(win32ƽ̨)
*/
#if defined(_WIN32) || defined(_WIN64)
2014-11-19 00:25:21 +08:00
SOCKET sock_handle() const;
#else
int sock_handle() const;
#endif
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>İ󶨹<EFBFBD>ϵ<EFBFBD><EFBFBD>ͬʱ<EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD>ֵĹ<EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>رո<EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD>ӹܸ<EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> close/open <EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD>(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {ACL_SOCKET} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ACL_SOCKET_INVALID <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD>ֽ<EFBFBD><EFBFBD><EFBFBD>
*/
#if defined(_WIN32) || defined(_WIN64)
2014-11-19 00:25:21 +08:00
SOCKET unbind_sock();
#else
int unbind_sock();
#endif
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵĵ<EFBFBD>ַ
* @param full {bool} <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP:PORT<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD>
* Ϊ false<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򷵻<EFBFBD> IP:PORT
* @return {const char*} Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ == '\0' <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
* <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>ַ
*/
const char* get_peer(bool full = false) const;
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD> IP <EFBFBD><EFBFBD>ַ
* @return {const char*} Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ == '\0' <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
* <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>ַ
*/
const char* get_peer_ip() const;
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TCP <EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD>̶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>UDP <EFBFBD><EFBFBD><EFBFBD>ʽʱ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD>̵<EFBFBD>ַ<EFBFBD><EFBFBD>Ȼ<EFBFBD><EFBFBD>
* <EFBFBD>ſ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param addr {const char*} Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>ip:port
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> false
*/
bool set_peer(const char* addr);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵı<EFBFBD><EFBFBD>ص<EFBFBD>ַ
* @param full {bool} <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP:PORT<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD>
* Ϊ false<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򷵻<EFBFBD> IP:PORT
* @return {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵı<EFBFBD><EFBFBD>ص<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ == "" <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
* <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD>ص<EFBFBD>ַ
*/
const char* get_local(bool full = false) const;
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵı<EFBFBD><EFBFBD><EFBFBD> IP <EFBFBD><EFBFBD>ַ
* @return {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵı<EFBFBD><EFBFBD>ص<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ == "" <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
* <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD>ص<EFBFBD>ַ
*/
const char* get_local_ip() const;
/**
* <EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD>ص<EFBFBD>ַ
* @param addr {const char*} <EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>ip:port
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> false
*/
bool set_local(const char* addr);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵĴ<EFBFBD><EFBFBD><EFBFBD>״̬(<EFBFBD>ڲ<EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̽<EFBFBD><EFBFBD>)
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD>򿪻<EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD>ر<EFBFBD>ʱ<EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> false<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򷵻<EFBFBD> true
*/
bool alive() const;
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> TCP <EFBFBD>׽<EFBFBD><EFBFBD>ֵ<EFBFBD> nodelay <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param on {bool} true <EFBFBD><EFBFBD>ʾ<EFBFBD>򿪣<EFBFBD>false <EFBFBD><EFBFBD>ʾ<EFBFBD>ر<EFBFBD>
* @return {socket_stream&}
*/
socket_stream& set_tcp_nodelay(bool on);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> TCP <EFBFBD>׽<EFBFBD><EFBFBD>ֵ<EFBFBD> SO_LINGER ѡ<EFBFBD><EFBFBD>
* @param on {bool} <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> SO_LINGER ѡ<EFBFBD><EFBFBD>
* @param linger {int} <EFBFBD><EFBFBD>SO_LINGER<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD> timed_wait <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>λΪ<EFBFBD><EFBFBD>
* @return {socket_stream&}
*/
socket_stream& set_tcp_solinger(bool on, int linger);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> TCP <EFBFBD>׽<EFBFBD><EFBFBD>ֵ<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
* @param size {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD>С
* @return {socket_stream&}
*/
socket_stream& set_tcp_sendbuf(int size);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> TCP <EFBFBD>׽<EFBFBD><EFBFBD>ֵĶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
* @param size {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD>С
* @return {socket_stream&}
*/
socket_stream& set_tcp_recvbuf(int size);
2015-01-14 23:35:23 +08:00
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> TCP <EFBFBD>׽<EFBFBD><EFBFBD>ֵķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
* @param on {bool} <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ true ʱ<EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
* @return {socket_stream&}
*/
socket_stream& set_tcp_non_blocking(bool on);
2014-11-19 00:25:21 +08:00
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> TCP <EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> nodelay ѡ<EFBFBD><EFBFBD>
* @return {bool} true <EFBFBD><EFBFBD>ʾ<EFBFBD>򿪣<EFBFBD>false <EFBFBD><EFBFBD>ʾ<EFBFBD>ر<EFBFBD>
*/
bool get_tcp_nodelay();
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> TCP <EFBFBD>׽<EFBFBD><EFBFBD>ֵ<EFBFBD> linger ֵ
* @param fd {ACL_SOCKET} <EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD>
* @return {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> -1 <EFBFBD><EFBFBD>ʾδ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> linger ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>= 0
* <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> linger ѡ<EFBFBD><EFBFBD><EFBFBD>Ҹ<EFBFBD>ֵ<EFBFBD><EFBFBD>ʾ<EFBFBD>׽<EFBFBD><EFBFBD>ֹرպ<EFBFBD><EFBFBD><EFBFBD> TCP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ں<EFBFBD><EFBFBD><EFBFBD>
* ά<EFBFBD><EFBFBD> TIME_WAIT ״̬<EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
*/
int get_tcp_solinger();
/**
* <EFBFBD><EFBFBD>ȡ TCP <EFBFBD>׽<EFBFBD><EFBFBD>ֵ<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
* @param fd {ACL_SOCKET} <EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD>
* @return {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
*/
int get_tcp_sendbuf();
/**
* <EFBFBD><EFBFBD>ȡ TCP <EFBFBD>׽<EFBFBD><EFBFBD>ֵĶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
* @param fd {ACL_SOCKET} <EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD>
* @return {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
*/
int get_tcp_recvbuf();
2015-01-14 23:35:23 +08:00
/**
* <EFBFBD>жϵ<EFBFBD>ǰ<EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
* @return {bool}
* ע<EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><EFBFBD><EFBFBD>Ŀǰ<EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD> UNIX ƽ̨
*/
bool get_tcp_non_blocking();
2014-11-19 00:25:21 +08:00
private:
char dummy_[1];
2017-04-11 23:14:39 +08:00
char peer_ip_[256];
char local_ip_[256];
2014-11-19 00:25:21 +08:00
const char* get_ip(const char* addr, char* buf, size_t size);
};
} // namespace acl