POCO庫中文程式設計參考指南(3)Poco::Net::Socket
POCO庫中文程式設計參考指南(3)Poco::Net::Socket
- 作者:柳大·Poechant
- 部落格:Blog.CSDN.net/Poechant
- 郵箱:zhongchao.ustc#gmail.com (# -> @)
- 日期:April 14th, 2012
1 SelectMode
enum SelectMode
/// The mode argument to poll() and select().
{
SELECT_READ = 1,
SELECT_WRITE = 2,
SELECT_ERROR = 4
};
2 SocketList
typedef std::vector<Socket> SocketList;
3 建構函式
未初始化的 socket:
Socket();
拷貝建構函式
Socket(const Socket& socket);
4 過載運算子
賦值運算子:
Socket& operator = (const Socket& socket);
比較運算子:
bool operator == (const Socket& socket) const;
bool operator != (const Socket& socket) const;
bool operator < (const Socket& socket) const;
bool operator <= (const Socket& socket) const;
bool operator > (const Socket& socket) const;
bool operator >= (const Socket& socket) const;
5 常用 socket 操作
返回該 socket 的可讀資料的位元組數,該操作不引起 socket 阻塞:
int available() const;
關閉 socket:
void close();
poll:
bool poll(const Poco::Timespan& timeout, int mode) const;
/// Determines the status of the socket, using a
/// call to select().
///
/// The mode argument is constructed by combining the values
/// of the SelectMode enumeration.
///
/// Returns true if the next operation corresponding to
/// mode will not block, false otherwise.
SocketImpl* impl() const;
/// Returns the SocketImpl for this socket.
檢查這個 socket 的連線是否是安全的(使用 SSL 或 TLS):
bool secure() const;
6 緩衝區
傳送資料的緩衝區:
void setSendBufferSize(int size);
int getSendBufferSize() const;
接收資料的緩衝區:
void setReceiveBufferSize(int size);
int getReceiveBufferSize() const;
7 超時時間
傳送資料的超時時間:
void setSendTimeout(const Poco::Timespan& timeout);
Poco::Timespan getSendTimeout() const;
接收資料的超時時間:
void setReceiveTimeout(const Poco::Timespan& timeout);
Poco::Timespan getReceiveTimeout() const;
8 其他介面
void setOption(int level, int option, int value);
void setOption(int level, int option, unsigned value);
void setOption(int level, int option, unsigned char value);
void setOption(int level, int option, const Poco::Timespan& value);
void setOption(int level, int option, const IPAddress& value);
void getOption(int level, int option, int& value) const;
void getOption(int level, int option, unsigned& value) const;
void getOption(int level, int option, unsigned char& value) const;
void getOption(int level, int option, Poco::Timespan& value) const;
void getOption(int level, int option, IPAddress& value) const;
void setLinger(bool on, int seconds);
void getLinger(bool& on, int& seconds) const;
void setNoDelay(bool flag);
bool getNoDelay() const;
void setKeepAlive(bool flag);
bool getKeepAlive() const;
void setReuseAddress(bool flag);
bool getReuseAddress() const;
void setReusePort(bool flag);
bool getReusePort() const;
void setOOBInline(bool flag);
bool getOOBInline() const;
void setBlocking(bool flag);
bool getBlocking() const;
獲取 socket 的 IP 和埠:
SocketAddress address() const;
獲取 peer socket 的 IP 地址和埠:
SocketAddress peerAddress() const;
9 靜態函式
select:
static int select(SocketList& readList,
SocketList& writeList,
SocketList& exceptList,
const Poco::Timespan& timeout);
/// Determines the status of one or more sockets,
/// using a call to select().
///
/// ReadList contains the list of sockets which should be
/// checked for readability.
///
/// WriteList contains the list of sockets which should be
/// checked for writeability.
///
/// ExceptList contains a list of sockets which should be
/// checked for a pending error.
///
/// Returns the number of sockets ready.
///
/// After return,
/// * readList contains those sockets ready for reading,
/// * writeList contains those sockets ready for writing,
/// * exceptList contains those sockets with a pending error.
///
/// If the total number of sockets passed in readList, writeList and
/// exceptList is zero, select() will return immediately and the
/// return value will be 0.
///
/// If one of the sockets passed to select() is closed while
/// select() runs, select will return immediately. However,
/// the closed socket will not be included in any list.
/// In this case, the return value may be greater than the sum
/// of all sockets in all list.
檢查是否支援 IPv4 或 IPv6:
static bool supportsIPv4();
static bool supportsIPv6();
-
轉載請註明來自柳大的CSDN部落格:Blog.CSDN.net/Poechant
-
相關文章
- poco節點關係大公開!
- Airtest (poco 框架) 元素定位實戰AI框架
- C++跨平臺庫boost和Poco的編譯C++編譯
- Python 中的 Socket 程式設計(指南)Python程式設計
- Spring Boot 2.0.2 參考指南(通用的應用程式屬性 ②)中文文件Spring Boot
- 【python socket程式設計】—— 3.響應Python程式設計
- BOOST庫 學習參考完全開發指南
- SOCKET程式設計程式設計
- Poco框架實操:對節點可實施的操作框架
- python資源庫——socket網路程式設計Python程式設計
- Global.asa程式設計完全參考手冊程式設計
- Hbase 中文參考指南 3.0 校對活動發車了~
- Mimikatz 非官方指南和命令參考_Part3
- Java Socket程式設計Java程式設計
- socket程式設計(1)程式設計
- Socket程式設計模型程式設計模型
- Python socket程式設計Python程式設計
- Spring Boot 參考指南(Hazelcast)Spring BootAST
- Elasticsearch 參考指南(介紹)Elasticsearch
- GraalVM快速參考指南 - graalvmLVM
- 湘潭大學2018年上學期程式設計實踐模擬考試3 參考題解程式設計
- Poco 框架實操:獲取節點屬性的高效技巧 (一)框架
- Poco框架實操:獲取節點屬性的高效技巧(一)框架
- 國外APP介面設計參考APP
- Socket程式設計基礎程式設計
- socket網路程式設計程式設計
- 網路程式設計-socket程式設計
- socket程式設計實戰程式設計
- 幽默:真正的程式設計師閱讀API參考文件程式設計師API
- Spring Boot 參考指南(目錄)Spring Boot
- Spring Boot 參考指南(Quartz Scheduler)Spring Bootquartz
- MySQL & MariaDB Online DDL 參考指南MySql
- Go 語言使用.NET 包實現 Socket 網路程式設計Go程式設計
- (3)Tcp Socket程式設計的封裝類 TcpListener/TcpClientTCP程式設計封裝client
- DOJO API 中文參考手冊API
- MySQL8-中文參考-三-MySql
- POCO相簿的照片批量採集下載的簡單方法有嗎?
- C# 9 record 並非簡單屬性 POCO 的語法糖C#
- ACCPS2-03使用java實現資料庫程式設計考試試題參照Java資料庫程式設計