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_GIGABASE_NAMESPACE
00017
00018 class unix_socket : public socket_t {
00019 protected:
00020 int fd;
00021 socket_domain domain;
00022 bool create_file;
00023
00024 enum error_codes {
00025 ok = 0,
00026 not_opened = -1,
00027 bad_address = -2,
00028 connection_failed = -3,
00029 broken_pipe = -4,
00030 invalid_access_mode = -5
00031 };
00032
00033 public:
00034
00035
00036
00037
00038 static char* unix_socket_dir;
00039
00040 bool open(int listen_queue_size);
00041 bool connect(int max_attempts, time_t timeout);
00042
00043 int read(void* buf, size_t min_size, size_t max_size,
00044 time_t timeout);
00045 bool write(void const* buf, size_t size);
00046
00047 bool is_ok();
00048 bool shutdown();
00049 bool close();
00050 char* get_peer_name();
00051 void get_error_text(char_t* buf, size_t buf_size);
00052
00053 socket_t* accept();
00054 bool cancel_accept();
00055
00056 unix_socket(const char* address, socket_domain domain);
00057 unix_socket(int new_fd);
00058
00059 ~unix_socket();
00060 };
00061
00062 END_GIGABASE_NAMESPACE
00063
00064 #endif
00065
00066
00067
00068
00069