FileSenderThread.h
上传用户:maryhy001
上传日期:2007-05-02
资源大小:2317k
文件大小:2k
源码类别:

网格计算

开发平台:

Visual C++

  1. #ifndef _FILESENDER_THREAD_H
  2. #define _FILESENDER_THREAD_H
  3. #include "package.h"
  4. #include "mutex.h"
  5. #include "thread.h"
  6. #include "xfile.h"
  7. #include "socket.h"
  8. #include "safeVector.h"
  9. class CFileSenderSocket;
  10. //class CFileSenderThread ::  client socket sending file thread.
  11. //   it inherited from CThread class.
  12. class NETLIBDLLEXPORT CFileSenderThread : public CThread
  13. {
  14. public:
  15. CFileSenderThread();
  16. virtual ~CFileSenderThread();
  17. //create the thread
  18. bool Create(bool bCreateAndSuspended = false, 
  19. const char* lpszSvrIpAddr = "127.0.0.1", 
  20. uint unPort = 8989);
  21. //
  22. bool Create(bool bCreateAndSuspended = false, 
  23. CXClientSocket *pSndSocket = NULL);
  24. //destroy the thread
  25. virtual void Destroy();
  26. //set the sending notify event receiver window..
  27. void Subscribe( HWND hNotifyWnd = NULL );
  28. //push the file item.
  29. void pushFile(const char *szFileName);
  30. protected:
  31. //send someone file contents.
  32. int SendFile(string &strfilename);
  33. int SendFileHeader(string &strfilename);
  34. int SendFileBody();
  35. int SendContSignal( bool bIsContinue = true );
  36. //overrides execute function.
  37. virtual void Execute();
  38. //start, stop event process functions.
  39. virtual void OnStart();
  40. virtual void OnStop();
  41. private:
  42. //file sending socket object.
  43. CXClientSocket *m_pSndSocket;
  44. //sending file name list.
  45. CSafeStringList m_lstFileNames;
  46. //current file object...
  47. CXFile m_xfile;
  48. //event receiver ...
  49. HWND m_hNotifyWnd;
  50. //mutex object.
  51. CMutex m_hMutex;
  52. };
  53. #endif //_FILESENDER_THREAD_H