Networking Tools: Network Communication Classes (net library)
#include <rw/toolpro/sockatt.h> RWSocketAttribute(socket, RWSocketAttribute::CANREAD)
net, tls (and possibly std)
The RWSocketAttribute class encapsulates conditions that may be true for a socket. An RWSocketAttribute serves two purposes: it is used to represent a set of attributes on a socket in which you may be interested, and it is used to indicate that a particular attribute is true. It consists of two parts: the socket and the attribute.
The RWSocketAttribute class is used by the global function select() (described in RWSocket) to do asynchronous I/O.
RWSocketAttribute();
Constructs a null attribute on the undefined socket.
RWSocketAttribute(const RWSocket& socket, Attribute attribute=NIL);
Constructs an attribute for a particular socket.
RWSocketAttribute(const RWSocketAttribute& x);
Creates a copy of x.
enum Attribute { sock_attr_nil = 0, // placebo sock_attr_canread = 1, // Data available for reading sock_attr_canwrite = 2, // Data available for writing sock_attr_exception = 4, // An exception, such as an // error or of band data sock_attr_isconnected = 8, // Connect has completed sock_attr_canaccept = 32, // A new connection is ready // to be accepted sock_attr_any = ~0 // Interested in any Attribute };
The Attribute type indicates the condition(s) on the socket. Attributes are used both to indicate conditions of interest, and to indicate what has happened on the socket. Attributes can be aggregated by ORing them together. For example, the attribute sock_attr_canread|sock_attr_canwrite on a socket indicates that the socket can either read or write.
The pre-Tools.h++ Professional enum values (NILL, CANREAD, CANWRITE, EXCEPTION, ISCONNECTED, CANACCEPT, ANY) have been retained, but are deprecated. You can keep the compiler from seeing the old values by defining RW_AVOID_PREPROCESSOR_PROBLEMS.
RWSocketAttribute& operator=(const RWSocketAttribute& x);
Makes self a copy of x. The previous contents of self are lost.
Attribute attribute() const;
The attribute with which this is associated. The attribute may be a set of several Attributes ORed together.
RWSocket socket() const;
The socket with which the attribute is associated.
RWTValOrderedVector RWTValOrderedVector<RWSocketAttribute> rwSocketSelect(const RWTValOrderedVector<RWSocketAttribute>& attributes);
Waits for one of the conditions specified by the list attributes to occur and returns a list of the conditions that have occurred. If any of the conditions has already occurred when the function is called, it returns immediately. Otherwise, it blocks indefinitely waiting for a condition to become true.
This function returns RWSocketAttribute::sock_attr_canwrite on stream sockets that are not connected. This is a problem with the underlying select() function. It should not affect most users, since you probably don't want to call rwSocketSelect() on sockets that are not connected.
RWTValOrderedVector<RWSocketAttribute> rwSocketSelect(const RWTValOrderedVector<RWSocketAttribute>& attributes, double timeout);
Waits for one of the conditions specified by the list attributes to occur and returns a list of the conditions that have occurred. If any of the conditions has already occurred when the function is called, it returns immediately. Otherwise, it blocks for up to timeout seconds waiting for a condition to become true.
This function returns RWSocketAttribute::sock_attr_canwrite on stream sockets that are not connected. This is a problem with the underlying select() function. It should not affect most users, since you probably don't want to call rwSocketSelect() on sockets that are not connected.
RWBoolean operator==(const RWSocketAttribute& x, const RWSocketAttribute& y);
True if x and y refer to the same attribute on the same socket.
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.