00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __UNISOCK_H__
00012 #define __UNISOCK_H__
00013
00014 #include "sockio.h"
00015
00016 BEGIN_FASTDB_NAMESPACE
00017
00018 class unix_socket : public socket_t {
00019 protected:
00020 int fd;
00021 int errcode;
00022 char* address;
00023 socket_domain domain;
00024 bool create_file;
00025
00026 enum error_codes {
00027 ok = 0,
00028 not_opened = -1,
00029 bad_address = -2,
00030 connection_failed = -3,
00031 broken_pipe = -4,
00032 invalid_access_mode = -5
00033 };
00034
00035 public:
00036
00037
00038
00039
00040 static char* unix_socket_dir;
00041
00042 bool open(int listen_queue_size);
00043 bool connect(int max_attempts, time_t timeout);
00044
00045 int read(void* buf, size_t min_size, size_t max_size, time_t timeout);
00046 bool write(void const* buf, size_t size, time_t timeout);
00047
00048 bool is_ok();
00049 bool shutdown();
00050 bool close();
00051 char* get_peer_name();
00052 void get_error_text(char* buf, size_t buf_size);
00053
00054 socket_t* accept();
00055 bool cancel_accept();
00056
00057 int get_handle();
00058
00059 unix_socket(const char* address, socket_domain domain);
00060 unix_socket(int new_fd);
00061
00062 ~unix_socket();
00063 };
00064
00065 END_FASTDB_NAMESPACE
00066
00067 #endif
00068
00069
00070
00071
00072