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,
00046 time_t timeout);
00047 bool write(void const* buf, size_t size);
00048
00049 bool is_ok();
00050 bool shutdown();
00051 bool close();
00052 char* get_peer_name();
00053 void get_error_text(char* buf, size_t buf_size);
00054
00055 socket_t* accept();
00056 bool cancel_accept();
00057
00058 int get_handle();
00059
00060 unix_socket(const char* address, socket_domain domain);
00061 unix_socket(int new_fd);
00062
00063 ~unix_socket();
00064 };
00065
00066 END_FASTDB_NAMESPACE
00067
00068 #endif
00069
00070
00071
00072
00073