Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef GNASH_SOCKET_H
00022 #define GNASH_SOCKET_H
00023
00024 #include "dsodefs.h"
00025 #include <boost/cstdint.hpp>
00026 #include "IOChannel.h"
00027
00028 namespace gnash {
00029 class URL;
00030 }
00031
00032 namespace gnash {
00033
00035
00041 class DSOEXPORT Socket : public IOChannel
00042 {
00043 public:
00044
00046 Socket();
00047
00048 virtual ~Socket() {}
00049
00051
00055
00059 bool connect(const std::string& hostname, boost::uint16_t port);
00060
00062
00065 void close();
00066
00068
00072 bool connected() const;
00073
00075
00079 virtual bool bad() const {
00080 return _error;
00081 }
00082
00084
00085 virtual std::streamsize read(void* dst, std::streamsize num);
00086
00088 virtual std::streamsize readNonBlocking(void* dst, std::streamsize num);
00089
00091
00094
00096 virtual std::streamsize write(const void* src, std::streamsize num);
00097
00099
00101 virtual std::streampos tell() const;
00102
00104
00106 virtual bool seek(std::streampos p);
00107
00109
00111 virtual void go_to_end();
00112
00114
00118 virtual bool eof() const;
00119
00120 private:
00121
00123 void fillCache();
00124
00125 mutable bool _connected;
00126
00128 char _cache[16384];
00129
00131 int _socket;
00132
00134 int _size;
00135
00137 size_t _pos;
00138
00139 mutable bool _error;
00140 };
00141
00142 }
00143
00144 #endif // GNASH_IOCHANNEL_H
00145
00146
00147
00148
00149
00150