Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

socket.hh

Go to the documentation of this file.
00001 // socket.hh - source file for the mailfilter program 00002 // Copyright (c) 2003 - 2004 Andreas Bauer <baueran@in.tum.de> 00003 // 00004 // This program is free software; you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation; either version 2 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 00017 // USA. 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; // Socket descriptor. 00045 int time_out; // Time out. 00046 static void connect_alarm (int); // Alarm handler. 00047 string* read_buffer; // Server replies after read (). 00048 bool ssl_used; // True if SSL encryption is 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

Generated on Sat Nov 27 14:29:56 2004 for mailfilter by doxygen 1.3.8