#include <OSGSocketSelection.h>
Public Member Functions | |
Constructors | |
| * | SocketSelection () |
| Constructor. | |
| SocketSelection (const SocketSelection &source) | |
| Copy constructor. | |
Destructor | |
| * | ~SocketSelection () |
| Destructor. | |
SocketSelection functions | |
| *void | clear (void) |
| Clear all settings. | |
| void | clearRead (const Socket &soc) |
| Clear read settings for the given socket. | |
| void | clearWrite (const Socket &soc) |
| Clear write settings for the given socket. | |
| void | setRead (const Socket &soc) |
| Set read flag for the given socket. | |
| void | setWrite (const Socket &soc) |
| Set write flag for the given socket. | |
| bool | isSetRead (const Socket &soc) |
| Check if read flag is set for a socket. | |
| bool | isSetWrite (const Socket &soc) |
| Check if write flag is set for a socket. | |
| int | select (double time) |
| Start selection. | |
| int | select (double time, SocketSelection &result) const |
| Start selection. | |
assignment | |
| *const SocketSelection & | operator= (const SocketSelection &source) |
| assignment | |
Protected Attributes | |
| fd_set | _fdSetRead |
| fd_set | _fdSetWrite |
Example:
SocketSelection sel;
Socket s1,s2;
...
sel.setRead(s1);
sel.setRead(s2);
if(sel.select(2))
{
if(sel.isSetRead(s1)) cout << "Data on s1" << endl;
if(sel.isSetRead(s2)) cout << "Data on s2" << endl;
}
else
{
cout << "No data after 2 seconds" << endl;
}
Definition at line 63 of file OSGSocketSelection.h.
|
|
Definition at line 116 of file OSGSocketSelection.cpp. References clear(). 00117 { 00118 clear(); 00119 }
|
|
|
Definition at line 124 of file OSGSocketSelection.cpp. 00124 : 00125 _fdSetRead (source._fdSetRead), 00126 _fdSetWrite(source._fdSetWrite) 00127 { 00128 }
|
|
|
Definition at line 133 of file OSGSocketSelection.cpp.
|
|
|
Definition at line 140 of file OSGSocketSelection.cpp. References _fdSetRead, and _fdSetWrite. Referenced by SocketSelection(). 00141 { 00142 FD_ZERO(&_fdSetRead); 00143 FD_ZERO(&_fdSetWrite); 00144 }
|
|
|
Definition at line 150 of file OSGSocketSelection.cpp. References _fdSetRead, and osg::Socket::_sd. Referenced by osg::GroupSockConnection::wait(). 00151 { 00152 FD_CLR(sock._sd,&_fdSetRead); 00153 }
|
|
|
Definition at line 159 of file OSGSocketSelection.cpp. References _fdSetWrite, and osg::Socket::_sd. 00160 { 00161 FD_CLR(sock._sd,&_fdSetWrite); 00162 }
|
|
|
Definition at line 168 of file OSGSocketSelection.cpp. References _fdSetRead, and osg::Socket::_sd. Referenced by osg::GroupMCastConnection::checkChannels(), osg::PointMCastConnection::recvNextDgram(), osg::GroupSockConnection::selectChannel(), osg::GroupSockConnection::wait(), and osg::Socket::waitReadable(). 00169 { 00170 FD_SET(sock._sd,&_fdSetRead); 00171 }
|
|
|
Definition at line 177 of file OSGSocketSelection.cpp. References _fdSetWrite, and osg::Socket::_sd. Referenced by osg::Socket::waitWritable(). 00178 { 00179 FD_SET(sock._sd,&_fdSetWrite); 00180 }
|
|
|
Definition at line 249 of file OSGSocketSelection.cpp. References _fdSetRead, and osg::Socket::_sd. Referenced by osg::GroupMCastConnection::checkChannels(), osg::PointMCastConnection::recvNextDgram(), osg::GroupSockConnection::selectChannel(), and osg::GroupSockConnection::wait(). 00250 { 00251 if(FD_ISSET(sock._sd, &_fdSetRead)) 00252 return true; 00253 else 00254 return false; 00255 }
|
|
|
Definition at line 261 of file OSGSocketSelection.cpp. References _fdSetWrite, and osg::Socket::_sd. 00262 { 00263 if(FD_ISSET(sock._sd, &_fdSetWrite)) 00264 return true; 00265 else 00266 return false; 00267 }
|
|
|
Wait for the first read or write flag to be true. All other flags are cleared.
Definition at line 191 of file OSGSocketSelection.cpp. References _fdSetRead, and _fdSetWrite. Referenced by osg::GroupMCastConnection::checkChannels(), osg::PointMCastConnection::recvNextDgram(), select(), osg::GroupSockConnection::selectChannel(), osg::GroupSockConnection::wait(), osg::Socket::waitReadable(), and osg::Socket::waitWritable(). 00192 { 00193 timeval tVal,*tValP; 00194 int count; 00195 00196 if(duration<0) 00197 { 00198 tValP=NULL; 00199 } 00200 else 00201 { 00202 tVal.tv_sec = int( duration ); 00203 tVal.tv_usec = int( (duration-tVal.tv_sec)*1000000 ); 00204 tValP=&tVal; 00205 } 00206 do 00207 { 00208 count=::select(FD_SETSIZE, 00209 &_fdSetRead, 00210 &_fdSetWrite, 00211 NULL, 00212 tValP); 00213 if(count < 0) 00214 { 00215 #ifndef WIN32 00216 // select was interrupted by a signal. Ignore this 00217 // and retry to select 00218 if(errno != EINTR) 00219 throw SocketError("select()"); 00220 #else 00221 throw SocketError("select()"); 00222 #endif 00223 } 00224 } 00225 while(count < 0); 00226 return count; 00227 }
|
|
||||||||||||
|
Wait for the first read or write flag to be true. The resulting flags are set in result.
Definition at line 239 of file OSGSocketSelection.cpp. References select(). 00240 { 00241 result=*this; 00242 return result.select(duration); 00243 }
|
|
|
Definition at line 274 of file OSGSocketSelection.cpp. References _fdSetRead, and _fdSetWrite. 00275 { 00276 _fdSetRead =source._fdSetRead; 00277 _fdSetWrite=source._fdSetWrite; 00278 return *this; 00279 }
|
|
|
Definition at line 108 of file OSGSocketSelection.h. Referenced by clear(), clearRead(), isSetRead(), operator=(), select(), and setRead(). |
|
|
Definition at line 109 of file OSGSocketSelection.h. Referenced by clear(), clearWrite(), isSetWrite(), operator=(), select(), and setWrite(). |
1.4.3