/** ** File ......... MetainfoSocket.h ** Published .... 2005-06-14 ** Author ....... grymse@alhem.net **/ /* Copyright (C) 2005 Anders Hedstrom This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _METAINFOSOCKET_H #define _METAINFOSOCKET_H #include #include //! Sending and receiving end of metainfo file transfer class MetainfoSocket : public TcpSocket { enum state_t { STATE_GET_LENGTH = 0, STATE_GET_FILE, }; public: MetainfoSocket(SocketHandler& ); MetainfoSocket(SocketHandler& ,const std::string& filename); ~MetainfoSocket(); void OnAccept(); void OnConnect(); // void OnRawData(const char *,size_t); void OnDelete(); void OnRead(); private: MetainfoSocket(const MetainfoSocket& s) : TcpSocket(s) {} // copy constructor MetainfoSocket& operator=(const MetainfoSocket& ) { return *this; } // assignment operator void InitSession(); static int m_nr; int m_filenr; std::string m_filename; FILE *m_fil; state_t m_state; off_t m_sz; off_t m_sz_read; }; #endif // _METAINFOSOCKET_H