Stupid winsock needs special way to close sockets.
[dftpd.git] / Data.hpp
blob9f8a1c89e5fa2557dd4c493558cb1ac219a2d955
1 #ifndef __DFTPD__DATA_HPP__
2 #define __DFTPD__DATA_HPP__
4 #include <stdio.h>
5 #include <string>
6 #include <list>
7 #include <boost/shared_ptr.hpp>
8 #include "SessionPtr.hpp"
9 #include "DataBuffer.hpp"
11 #ifdef SYMBIAN
12 #include <f32file.h>
13 #endif
15 class Data
17 enum { BufSize = 524288 };
19 public:
20 enum Mode
22 M_UPLOAD,
23 M_DOWNLOAD,
26 #ifdef SYMBIAN
27 Data( const SessionWPtr& session, RFile* file, Mode mode );
28 #endif
29 Data( const SessionWPtr& session, FILE* file, Mode mode );
30 Data( const SessionWPtr& session, const std::list<std::string>& list );
31 ~Data();
33 bool Connect( const std::string& addr, int port );
34 bool Accept( int sock );
36 void Tick();
38 int GetSock() const { return m_sock; }
39 Mode GetMode() const { return m_mode; }
41 private:
42 void Send();
43 void Receive();
45 bool CanSend();
46 bool CanReceive();
48 int m_sock;
49 Mode m_mode;
50 SessionWPtr m_session;
51 char* m_buf;
52 DataBufferPtr m_data;
55 typedef boost::shared_ptr<Data> DataPtr;
57 #endif