1 //-< UNISOCK.H >-----------------------------------------------------*--------* 2 // FastDB Version 1.0 (c) 1997 GARRET * ? * 3 // (Main Memory Database Management System) * /\| * 4 // * / \ * 5 // Created: 7-Jan-97 K.A. Knizhnik * / [] \ * 6 // Last update: 7-Jan-97 K.A. Knizhnik * GARRET * 7 //-------------------------------------------------------------------*--------* 8 // Unix socket 9 //-------------------------------------------------------------------*--------* 10 11 #ifndef __UNISOCK_H__ 12 #define __UNISOCK_H__ 13 14 #include "sockio.h" 15 16 BEGIN_FASTDB_NAMESPACE 17 18 class unix_socket : public socket_t { 19 protected: 20 int fd; 21 int errcode; // error code of last failed operation 22 char* address; // host address 23 socket_domain domain; // Unix domain or INET socket 24 bool create_file; // Unix domain sockets use files for connection 25 26 enum error_codes { 27 ok = 0, 28 not_opened = -1, 29 bad_address = -2, 30 connection_failed = -3, 31 broken_pipe = -4, 32 invalid_access_mode = -5 33 }; 34 35 public: 36 // 37 // Directory for Unix Domain socket files. This directory should be 38 // either empty or be terminated with "/". Dafault value is "/tmp/" 39 // 40 static char* unix_socket_dir; 41 42 bool open(int listen_queue_size); 43 bool connect(int max_attempts, time_t timeout); 44 45 int read(void* buf, size_t min_size, size_t max_size, time_t timeout); 46 bool write(void const* buf, size_t size, time_t timeout); 47 48 bool is_ok(); 49 bool shutdown(); 50 bool close(); 51 char* get_peer_name(); 52 void get_error_text(char* buf, size_t buf_size); 53 54 socket_t* accept(); 55 bool cancel_accept(); 56 57 socket_handle_t get_handle(); 58 59 unix_socket(const char* address, socket_domain domain); 60 unix_socket(int new_fd); 61 62 ~unix_socket(); 63 }; 64 65 END_FASTDB_NAMESPACE 66 67 #endif 68 69 70 71 72 73