#pragma warning ( disable:4005 ) #pragma warning ( disable:4996 ) #ifdef _WIN32 #include #include #include #define MSG_NOSIGNAL 0 #endif #include #include #include "../Interface/Thread.h" #include "bufmgr.h" #include "tcpstack.h" #include "data.h" #include "types.h" #include "settings.h" class CTCPFileServ; struct SSendData { char* buffer; unsigned int bsize; bool last; bool delbuf; char* delbufptr; }; struct SLPData { std::deque *t_send; std::vector *t_unsend; char* buffer; bool last; int filepart; int *sendfilepart; unsigned int bsize; }; class CClientThread : public IThread { public: CClientThread(SOCKET pSocket, CTCPFileServ* pParent); ~CClientThread(); bool isStopped(void); bool isKillable(void); void operator()(void); void StopThread(void); private: bool RecvMessage(void); bool ProcessPacket(CRData *data); void ReadFilePart(HANDLE hFile, const _i64 &offset,const bool &last); int SendData(void); void ReleaseMemory(void); void CloseThread(HANDLE hFile); void EnableNagle(void); void DisableNagle(void); SOCKET mSocket; bool stopped; bool killable; int currfilepart; int sendfilepart; CBufMgr* bufmgr; CTCPStack stack; char buffer[BUFFERSIZE]; std::deque t_send; std::vector t_unsend; HANDLE hFile; int errcount; bool close_the_socket; CTCPFileServ *parent; };