DSP application example (1) - Easily implement BT multi-point download Bittorrent ---- Abbreviation "BT" download, is now the most popular way of downloading, its main feature is how IP download, one file can be from multiple IP At the same time, download it to achieve the limit. In this packet, a standard DSPSPIDER class is provided, and you can easily implement BitTorrent multi-point download using this class. When using BitTorrent and FlashGet download, it is necessary to start the index of the disk to generate the entire file in advance. When the file is large, the creation time of the file will be longer, so that the system like cranes, actually Is in creating a file. DSPSpider uses a more advanced way, there is no need to scan the disk before downloading the file, and the file is dynamically created. As the download completion is gradually increased, no additional files are required during the download process. This release is a debug version, and there will be more and more complete features in the official version. Simply respond to seven messages in the form, you can easily implement BT multi-point download. 1 msg_recvsect Receiver message receives a part of the data, and the message is sent to the specified form when receiving a portion of the data. You must call DSPSPIDER.OnupdateSect (WPARAM, LPARAM), which will return the number of bytes currently downloaded. WPARAM - Pointer to the DSPSpider :: _ FileDetail structure LParam - The currently received byte number 2 MSG_sendComplete Receiver message receiving process is suspended, which may be that the file has been downloaded or downloaded. You must call DSPSPIDER.OnSendComplete (WPARAM, LPARAM), which will return a number if it returns 1, then the file has all been downloaded; if 2, the file has not been downloaded yet, but all threads have been terminated, the reason may It is an error that occurs during the termination or receiver termination or download process. For specific reasons for thread abort, you can get the specific reason for the error by calling the DSPSPIDER :: GetCompleteInfo (LPARAM, STR) function. WPARAM - Pointer to DSPSpider :: _ FileDetail LPARM - Error Cause 3 MSG_SETFileNameSize Receiver Message Transfer The currently received file size, file name, can set it here, the message is only sent once at the beginning of WPARAM - - Pointer DSPSPIDER.GETPROGRESSSSSTEP () gets the DSPSPIDER.GETCURSSSSSTEP () get the current length of the file 4 MSG_SHOWPROMPT Receiver message display prompt information, which will continue to send the message in the receipt of the file. , Pass the status of the current receiving process WPARAM - low 16-bit, message ID. High 16-bit low 8-bit, current download thread, high 8 digits, currently downloading the number of sleeping threads in the current download thread.
LPARAM - If not 0, the string of the IP address of the connection side represents the 5 msg_assignnewsect Receiver message This is a required message to directly call the DSPSPIDER.ONASSIGNEWSECT (WPARAM, LPARAM) function in the message. 6 MSG_CREATERECVTHREAD Receiver Message This is a necessary response message to call the DSPSpider.OncreateRecvthread (WPARAM, LPARAM) function in this message. 7 MSG_GETFILENAME Transfer Message This is a required message that determines the file name that needs to be transmitted based on the file name passed by the recipient when receiving a transfer request. WPARAM - Pointer to the DSPSpider :: _ FileDetail structure When you respond to the message, call DSPSPIDER :: SetFileName (WPARAM, STRPATHNAME), which will set the name of the transfer file and contain the path name. The structural description _sendthreadParam structure in DSPSPIDER, the structure you need to pass when listening threads is established. PCWND - The form of the message is received. If it is passed to the parameter of the listening thread, the form must respond to the MSG_GetFileName message. BINTERNET - whether it is an Internet application, True represents the Internet application; false represents a LAN application
_FileDetail structure, in response to the structure of the structure in response to the DSPSpider - contains the file name of the path, this variable is read-only, cannot change the StrFileName - the file name does not contain the path, this variable is read-only, can not change DWFILESize - The number of the current file number NfileID-file ID, is used to identify unique files, only as a reference value, if you do not want to set the ID, can be set to 0 Brun - Continue to receive or transfer, this value When TRUE, indicates that the attribute and function description type in the handle DSPSPIDER indicating that the current process hWnd - receives the message HWnd - receives the message: Property definition: DWORD M_DWERRORCODE Description: Error code, when an error occurs, The variable saves the error code, describing the reason type of the error: Property definition: BOOL M_BEXISTQUERY Description: Whether the file is inquired, if the value is false, the file name is present, no longer downloads the file, but the end. Type: Attribute Definition: BOOL M_BCRC Description: Do you want to check. When True, it is denoted whether the CRC check; false, the CRC check type is not performed: Property definition: BOOL M_BINTERNET Description: Whether it is an Internet application. When TRUE, indicating that the data is converted to network sequence processing; for false, it indicates that the data is a word sequence processing type: static method definition: static void setFileName (WPARAM WPARAM, CSTRING & STRPATHNAME) Description: When responding to MSG_GETFileName, call it Method, set the file name of the file containing the file to be transmitted. Type: Static Method Definition: Static Bool getCompleteInfo (int WHICH, CSTRING & STR) Description: In response to the MSG_SendComplete message, you can call the method to get a text description of the cause of the process.
Parameters: Which - MSG_sendcomplete message LPARM parameter STR - Save text description strings return: True - File has been downloaded to complete FALSE - The file has not been downloaded, the download process is aborted: Static method definition: static UINT LISTENTHREAD (LPVOID LPDATA) Description: Listening Thread Parameters: LPDATA - Points to the PCWnd parameters in the pointer structure of the DSPSpider :: _ SendThreadParam structure, saves the BINTERNET parameters in the pointer structure of the form of the MSG_GetFileName message, indicating that the monitor port number is Network sequence or PFUNC parameters in the word sequence structure indicate a pointer type of a function of processing monitoring response: Message Process Definition: LRESULT ONSENDCOMPLETE (WPARAM WPARAM, LPARAM LPARAM) Description: This method must be called in response to MSG_sendComplete. Type: Message Processing Function Definition: LRESULT OnUpdateSect (WPARAM WPARAM, LPARAM LPARAM) Description: This method must be called in response to MSG_Recvsect. Type: Message Processing Function Definition: LRESULT OnAssignNewsect (WPARAM WPARAM, LPARAM LPARAM) Description: This method must be called in response to MSG_ASSIGNEWSECT. Type: Message Processing Function Definition: LRESULT OnABort (WPARAM WPARAM, LPARAM LPARAM) Description: When the receiver wants to abort the entire receiving process during the reception process, call the method.
Parameters: WPARAM - Value is 0 lParam - Value is 0 Returns: 0 - Indicates that the receiving process is preparing to abort, but the receiving thread has not been aborted 1 - indicates that the receiving process has been aborted: Message Process Definition: LRESULT OncreateRecvthread (WPARAM WPARAM, LPARAM LPARAM) Description: In response to the message in response to MSG_createRecvthread, you must call the method type: method definition: Void SafeRelease () Description: Securely release resources, the method should be guaranteed before the DSPSpider object cancellation should be called once: Method Definition: Bool Addip (Const Char * LPSRVIP, Word Word, Word NPRIRITY = 0) Description: Add an IP parameter that can be downloaded: lpsrvip - IP or domain name WPORT - IP of the file can be downloaded NPRIRITY - Weighted value, the smaller weight value, will be prioritized. Returns: True - Add correctly. IP can be repeated, repeatedly adding the same IP, indicating that the IP creates multiple threads from the IP download FALSE - the IP error cannot be obtained: All IP is sorted by priority, using two-way insertion. An IP can only create a thread. Type: Method Definition: Void Removeip (Const Char * LPSRVIP) Description: Cancel a IP parameter for download: LPSRVIP - IP or domain name type that can download file: method definition: BOOL RunSpider (const char * lpfilename, const char * LPPathName, HWND, BYTE BYTHREADCOUNT, INT NFILEID = 0); Description: Preparation: LPFileName - The file name to download, does not include path name lppathname - the file name to download, including path name HWnd - Responding to the handle of the recipient message - the number of NFILEID-files for the number of threads that need to be downloaded at the same time: method definition: DWORD getProgressStep () Description: Get stepper type: method definition : DWORD getCurrsize () Description: get the currently downloaded length source program download: http://www.copathway.com/vchelp/file2003_3/dsp_sample.rar