00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef SOCKET_HH
00020 #define SOCKET_HH
00021
00022 #include <string>
00023 #include <csignal>
00024
00025 #if USE_SSL
00026 extern "C"
00027 {
00028 #include <openssl/ssl.h>
00029 #include <openssl/rand.h>
00030 }
00031 #endif
00032
00033 #include "connection.hh"
00034
00035 using namespace std;
00036
00037 #ifndef MAX_BYTES
00038 #define MAX_BYTES 512
00039 #endif
00040
00041 class Socket : public Connection
00042 {
00043 private:
00044 int sd;
00045 int time_out;
00046 static void connect_alarm (int);
00047 string* read_buffer;
00048 bool ssl_used;
00049 bool use_ssl (void) const;
00050 void set_ssl (bool);
00051
00052 public:
00053 Socket (void);
00054 void clear (void);
00055 int c_open (const char* host,
00056 int port,
00057 int time_out,
00058 int protocol);
00059 int c_close (void) const;
00060 int c_write (const char* command);
00061 int c_read (bool = false);
00062 const string* c_reply (void) const;
00063 };
00064
00065 #endif