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 constructors
Uninitialized socket:
Socket ();
Copy Constructors
Socket (const socket& socket);
4 Overloaded operators
Assignment operator:
socket& operator = (const socket& Socket);
Comparison operators:
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 Common socket operation
Returns the number of bytes of readable data for this socket, which does not cause the socket to block:
int available () const;
Close 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 won't block, false otherwise.
socketimpl* impl () const;
Returns the SocketImpl for this socket.
Check that the connection for this socket is secure (using SSL or TLS):
BOOL Secure () const;
6 buffer
Buffer to send data:
void setsendbuffersize (int size);
int getsendbuffersize () const;
Buffer to receive data:
void setreceivebuffersize (int size);
int getreceivebuffersize () const;
7 Timeout time
Timeout time to send data:
void Setsendtimeout (const poco::timespan& timeout);
Poco::timespan getsendtimeout () const;
Timeout time to receive data:
void Setreceivetimeout (const poco::timespan& timeout);
Poco::timespan getreceivetimeout () const;
8 Other interfaces
void setOption (int level, option int, int value);
void setOption (int level, option int, unsigned value);
void setOption (int level, option int, unsigned char value);
void setOption (int level, option int, const poco::timespan& value);
void setOption (int level, option int, 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;
To obtain the IP and port of the socket:
SocketAddress address () const;
Get the IP address and port of the peer socket:
SocketAddress peeraddress () const;
9 Static functions
Select
static int Select (socketlist& readlist, socketlist& writelist, Socketl
ist& 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///to checked for readability.
Writelist contains the list of sockets which should be///to checked for writeability.
Exceptlist contains a list of sockets which should be///to checked for a pending error.
Returns the number of sockets ready. After return,///* ReadList contains those sockets ready for reading,///* writelist C
Ontains those sockets ready for writing,///* Exceptlist contains those and sockets with a pending error. If The total number of sockets passed In ReadList, Writelist and///exceptlist is zero, select () would return immediately and the///return Valu
E'll be 0. If one of the sockets passed to select () are closed while///Select () runs, select'll return immed Iately.
However,///the closed socket won't be included into any list. In this case, the return value may is greater than the sum///of all sockets in all list.
Check to see if IPV4 or IPV6 are supported:
static bool SupportsIPv4 ();
static bool SupportsIPv6 ();
CSDN blog from Liuda: blog.csdn.net/poechant
View a full set of articles: Http://www.bianceng.cn/Programming/cplus/201301/35022.htm