rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWSocketAttribute Class Reference
[Essential Networking Module]

Represents a set of attributes on a socket. More...

#include <rw/network/RWSocketAttribute.h>

List of all members.

Public Types

enum  Attribute {
  sock_attr_nil, sock_attr_canread, sock_attr_canwrite, sock_attr_exception,
  sock_attr_isconnected, sock_attr_canaccept, sock_attr_any, NIL,
  CANREAD, CANWRITE, RWEXCEPTION, ISEXCEPTION,
  EXCEPTION, ISCONNECTED, CANACCEPT, ANY
}

Public Member Functions

 RWSocketAttribute ()
 RWSocketAttribute (const RWSocket &socket, Attribute attribute=NIL)
RWSocket getSocket () const
Attribute getAttribute () const

Related Functions

(Note that these are not member functions.)



bool operator== (const RWSocketAttribute &x, const RWSocketAttribute &y)
RWTValOrderedVector
< RWSocketAttribute
rwSocketSelect (const RWTValOrderedVector< RWSocketAttribute > &attributes)
RWTValOrderedVector
< RWSocketAttribute
rwSocketSelect (const RWTValOrderedVector< RWSocketAttribute > &, double timeout)

Detailed Description

RWSocketAttribute 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, and it is used to indicate that a particular attribute is true. It consists of two parts: the socket and the attribute.

RWSocketAttribute is used by the global function rwSocketSelect() for asynchronous I/O.


Member Enumeration Documentation

The Attribute type indicates the condition(s) on the socket. Attributes are used 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 later enum values (NIL, CANREAD, CANWRITE, RWEXCEPTION, ISEXCEPTION, EXCEPTION, ISCONNECTED, CANACCEPT, ANY) have been retained, but are deprecated. You can refuse support for these values by defining the macro RW_AVOID_PREPROCESSOR_PROBLEMS.

Enumerator:
sock_attr_nil 

placebo

sock_attr_canread 

Data is available for reading.

sock_attr_canwrite 

Data is available for writing.

sock_attr_exception 

An exception, such as an error or of band data

sock_attr_isconnected 

Connect has completed.

sock_attr_canaccept 

A new connection is ready to be accepted.

sock_attr_any 

Interested in any Attribute.

NIL 
Deprecated:
You can refuse support for this value by defining the macro RW_AVOID_PREPROCESSOR_PROBLEMS
CANREAD 
Deprecated:
You can refuse support for this value by defining the macro RW_AVOID_PREPROCESSOR_PROBLEMS
CANWRITE 
Deprecated:
You can refuse support for this value by defining the macro RW_AVOID_PREPROCESSOR_PROBLEMS
RWEXCEPTION 
Deprecated:
You can refuse support for this value by defining the macro RW_AVOID_PREPROCESSOR_PROBLEMS
ISEXCEPTION 
Deprecated:
You can refuse support for this value by defining the macro RW_AVOID_PREPROCESSOR_PROBLEMS
EXCEPTION 
Deprecated:
You can refuse support for this value by defining the macro RW_AVOID_PREPROCESSOR_PROBLEMS
ISCONNECTED 
Deprecated:
You can refuse support for this value by defining the macro RW_AVOID_PREPROCESSOR_PROBLEMS
CANACCEPT 
Deprecated:
You can refuse support for this value by defining the macro RW_AVOID_PREPROCESSOR_PROBLEMS
ANY 
Deprecated:
You can refuse support for this value by defining the macro RW_AVOID_PREPROCESSOR_PROBLEMS

Constructor & Destructor Documentation

RWSocketAttribute::RWSocketAttribute (  ) 

Constructs a null attribute on the undefined socket.

RWSocketAttribute::RWSocketAttribute ( const RWSocket socket,
Attribute  attribute = NIL 
)

Constructs an attribute for a particular socket.


Member Function Documentation

RWSocketAttribute::Attribute RWSocketAttribute::getAttribute (  )  const [inline]

The attribute with which this is associated. The attribute may be a set of several Attribute values ORed together.

RWSocket RWSocketAttribute::getSocket (  )  const [inline]

The socket with which the attribute is associated.


Friends And Related Function Documentation

bool operator== ( const RWSocketAttribute x,
const RWSocketAttribute y 
) [related]

Returns true if x and y refer to the same attribute(s) on the same socket.

RWTValOrderedVector< RWSocketAttribute > rwSocketSelect ( const RWTValOrderedVector< RWSocketAttribute > &  ,
double  timeout 
) [related]

This function helps to perform asynchronous socket input/output operations. It waits for one of the conditions in the user-defined attributes vector to occur, and returns a vector of the conditions that have occurred. If any of the conditions has already occurred when the function is called, it returns immediately.

The attributes parameter is a vector of socket attributes. If empty, the program may sleep indefinitely. If one of the attributes refers to an invalid socket, a RWNetInvalidSocketError exception is thrown. If more than FD_SETSIZE attributes are in the attributes vector, an exception is thrown.

This function is guaranteed to block up to timeout seconds while waiting for a condition to become true. If the parameter has a value less than 0, the method blocks indefinitely waiting for a condition to become true. If the value is greater than LONG_MAX, it will be truncated to LONG_MAX. Note that when using large timeout values, the fractional part may change due to rounding.

Note:
On stream sockets that are not connected,this function returns RWSocketAttribute::sock_attr_canwrite . This is a known issue with the underlying select() function, but it should not affect you. Most users do not want to call rwSocketSelect() on sockets that are not connected.
RWTValOrderedVector< RWSocketAttribute > rwSocketSelect ( const RWTValOrderedVector< RWSocketAttribute > &  attributes  )  [related]

This function helps to perform asynchronous socket input/output operations. It waits for one of the conditions in the user-defined attributes vector to occur, and returns a vector of the conditions that have occurred. If any of the conditions has already occurred when the function is called, it returns immediately.

The attributes parameter is a vector of socket attributes. If empty, the program may sleep indefinitely. If one of the attributes refers to an invalid socket, a RWNetInvalidSocketError exception is thrown. If more than FD_SETSIZE attributes are in the attributes vector, an exception is thrown.

Note:
On stream sockets that are not connected,this function returns RWSocketAttribute::sock_attr_canwrite . This is a known issue with the underlying select() function, but it should not affect you. Most users do not want to call rwSocketSelect() on sockets that are not connected.
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.