22 #ifndef IBRCOMMON_SOCKET_H_
23 #define IBRCOMMON_SOCKET_H_
80 ss << error <<
": " << ::strerror(error);
87 virtual const char*
what()
const throw()
89 return __what.c_str();
92 int error()
const {
return _errno; }
122 virtual
void down() throw (socket_exception) = 0;
128 virtual
int fd() const throw (socket_exception);
136 virtual
int release() throw (socket_exception);
141 void close() throw (socket_exception);
142 void shutdown(
int how) throw (socket_exception);
153 sa_family_t
get_family() const throw (socket_exception);
154 static sa_family_t
get_family(
int fd) throw (socket_exception);
159 static
bool hasSupport(const sa_family_t family, const
int type = SOCK_DGRAM, const
int protocol = 0) throw ();
188 void set_keepalive(
bool val,
int fd = -1) const throw (socket_exception);
189 void set_linger(
bool val,
int l = 1,
int fd = -1) const throw (socket_exception);
190 void set_reuseaddr(
bool val,
int fd = -1) const throw (socket_exception);
191 void set_nodelay(
bool val,
int fd = -1) const throw (socket_exception);
194 void init_socket(
int domain,
int type,
int protocol) throw (socket_exception);
196 void bind(
int fd, struct sockaddr *addr, socklen_t len) throw (socket_exception);
220 virtual void up() throw (socket_exception);
221 virtual
void down() throw (socket_exception);
223 ssize_t send(const
char *data,
size_t len,
int flags = 0) throw (
socket_error);
224 ssize_t recv(
char *data,
size_t len,
int flags = 0) throw (socket_error);
226 void set(CLIENT_OPTION opt,
bool val) throw (socket_error);
230 clientsocket(
int fd);
240 virtual void up() throw (socket_exception) = 0;
241 virtual
void down() throw (socket_exception) = 0;
243 void listen(
int connections) throw (socket_exception);
244 virtual clientsocket* accept(ibrcommon::
vaddress &addr) throw (socket_exception) = 0;
246 void set(SERVER_OPTION opt,
bool val);
250 serversocket(
int fd);
252 int _accept_fd(ibrcommon::
vaddress &addr) throw (socket_exception);
258 virtual void up()
throw (socket_exception) = 0;
259 virtual void down()
throw (socket_exception) = 0;
261 virtual ssize_t recvfrom(
char *buf,
size_t buflen,
int flags,
ibrcommon::vaddress &addr)
throw (socket_exception);
262 virtual void sendto(
const char *buf,
size_t buflen,
int flags,
const ibrcommon::vaddress &addr)
throw (socket_exception);
277 virtual void up()
throw (socket_exception);
278 virtual void down()
throw (socket_exception);
281 const File _filename;
292 virtual void up()
throw (socket_exception);
293 virtual void down()
throw (socket_exception);
298 void bind(
const File &file)
throw (socket_exception);
301 const File _filename;
313 virtual void up()
throw (socket_exception);
314 virtual void down()
throw (socket_exception);
331 virtual void up()
throw (socket_exception);
332 virtual void down()
throw (socket_exception);
334 const vaddress& get_address()
const;
339 void bind(
const vaddress &addr)
throw (socket_exception);
355 virtual void up()
throw (socket_exception);
356 virtual void down()
throw (socket_exception);
358 const vaddress& get_address()
const;
361 void bind(
const vaddress &addr)
throw (socket_exception);
370 virtual void up()
throw (socket_exception);
371 virtual void down()
throw (socket_exception);
377 void mcast_op(
int optname,
const vaddress &group,
const vinterface &iface)
throw (socket_exception);