|
ZNC trunk
|
Csocket style wrapper around libcurl-multi. More...
#include <CurlSock.h>
Inheritance diagram for CCurlSock:
Collaboration diagram for CCurlSock:Public Member Functions | |
| CCurlSock () | |
| virtual | ~CCurlSock () |
| virtual bool | GatherFDsForSelect (std::map< int, int16_t > &miiReadyFds, long &iTimeoutMS) |
| the hook we tie into to get events from csocket | |
| virtual bool | CheckFDs (const std::map< int, int16_t > &miiReadyFds) |
| reimplement this to do nothing as its not needed | |
| CURL * | Retr (const CS_STRING &sURL, const CS_STRING &sReferrer="") |
| initiates a GET style transfer, but the process doesn't get started until the next GatherFDsForSelect() is called | |
| virtual bool | GatherFDsForSelect (std::map< cs_sock_t, short > &miiReadyFds, long &iTimeoutMS) |
| called before select, typically you don't need to reimplement this just add sockets via Add and let the default implementation have its way | |
| virtual bool | FDsThatTriggered (const std::map< cs_sock_t, short > &miiReadyFds) |
| called when there are fd's belonging to this class that have triggered | |
| virtual bool | CheckFDs (const std::map< cs_sock_t, short > &miiReadyFds) |
| gets called to diff miiReadyFds with m_miiMonitorFDs, and calls FDsThatTriggered when appropriate. | |
| void | Add (cs_sock_t iFD, short iMonitorEvents) |
| adds a file descriptor to be monitored | |
| void | Remove (cs_sock_t iFD) |
| removes this fd from monitoring | |
| void | DisableMonitor () |
| causes this monitor to be removed | |
| bool | IsEnabled () const |
Protected Member Functions | |
| virtual void | OnCURLComplete (CURL *pCURL)=0 |
| called when the transfer associate with this CURL object is completed | |
| virtual size_t | OnHeader (CURL *pCURL, const char *pData, size_t uBytes) |
| called as header information for the document is returned | |
| virtual size_t | OnBody (CURL *pCURL, const char *pData, size_t uBytes) |
| called as the document is returned | |
Protected Attributes | |
| std::map< cs_sock_t, short > | m_miiMonitorFDs |
| bool | m_bEnabled |
Csocket style wrapper around libcurl-multi.
http://curl.haxx.se/libcurl/c/libcurl-multi.html This isn't finished, but this is my basic approach. I added a means to which Csocket can monitor file descriptors it doesn't directly control. This class hooks into that by virtue of a callback "GatherFDsForSelect" and ties that libcurl-multi. When Csocket looks for fd's to monitor, this class calls "curl_multi_socket_action" which does a couple things ...
The end point here is a non-blocking method to fetch documents via CURL within Csocket
| CCurlSock::CCurlSock | ( | ) |
|
virtual |
|
inlineinherited |
adds a file descriptor to be monitored
| iFD | the file descriptor |
| iMonitorEvents | bitset of events to monitor for ( |
|
virtualinherited |
gets called to diff miiReadyFds with m_miiMonitorFDs, and calls FDsThatTriggered when appropriate.
Typically you don't need to reimplement this.
| miiReadyFds | the map of all triggered fd's, not just the fd's from this class |
|
inlinevirtual |
reimplement this to do nothing as its not needed
|
inlineinherited |
causes this monitor to be removed
|
inlinevirtualinherited |
called when there are fd's belonging to this class that have triggered
| miiReadyFds | the map of fd's with the bits that triggered them ( |
|
virtualinherited |
called before select, typically you don't need to reimplement this just add sockets via Add and let the default implementation have its way
| miiReadyFds | fill with fd's to monitor and the associated bit to check them for ( |
| iTimeoutMS | the timeout to change to, setting this to -1 (the default) |
|
virtual |
the hook we tie into to get events from csocket
|
inlineinherited |
|
inlineprotectedvirtual |
called as the document is returned
|
protectedpure virtual |
called when the transfer associate with this CURL object is completed
|
inlineprotectedvirtual |
called as header information for the document is returned
|
inlineinherited |
removes this fd from monitoring
initiates a GET style transfer, but the process doesn't get started until the next GatherFDsForSelect() is called
| sURL | the target document |
| sReferrer | the referring URL |
Its important to check the man page on curl_easy_setopt for the various variables. Certain data is tracked and some is not.
|
protectedinherited |
|
protectedinherited |