22 #ifndef IBRCOMMON_SOCKET_H_
23 #define IBRCOMMON_SOCKET_H_
37 #include <sys/socket.h>
87 ss << error <<
": " << ::strerror(error);
94 virtual const char*
what()
const throw()
96 return __what.c_str();
99 int error()
const {
return _errno; }
131 virtual
void down() throw (socket_exception) = 0;
137 virtual
int fd() const throw (socket_exception);
145 virtual
int release() throw (socket_exception);
150 void close() throw (socket_exception);
151 void shutdown(
int how) throw (socket_exception);
162 sa_family_t
get_family() const throw (socket_exception);
163 static sa_family_t
get_family(
int fd) throw (socket_exception);
168 static
bool hasSupport(const sa_family_t family, const
int type = SOCK_DGRAM, const
int protocol = 0) throw ();
197 void set_keepalive(
bool val,
int fd = -1) const throw (socket_exception);
198 void set_linger(
bool val,
int l = 1,
int fd = -1) const throw (socket_exception);
199 void set_reuseaddr(
bool val,
int fd = -1) const throw (socket_exception);
200 void set_nodelay(
bool val,
int fd = -1) const throw (socket_exception);
203 void init_socket(
int domain,
int type,
int protocol) throw (socket_exception);
205 void bind(
int fd, struct sockaddr *addr, socklen_t len) throw (socket_exception);
229 virtual void up() throw (socket_exception);
230 virtual
void down() throw (socket_exception);
232 ssize_t send(const
char *data,
size_t len,
int flags = 0) throw (socket_exception);
233 ssize_t recv(
char *data,
size_t len,
int flags = 0) throw (socket_exception);
235 void set(CLIENT_OPTION opt,
bool val) throw (socket_exception);
239 clientsocket(
int fd);
249 virtual void up() throw (socket_exception) = 0;
250 virtual
void down() throw (socket_exception) = 0;
252 void listen(
int connections) throw (socket_exception);
253 virtual clientsocket* accept(ibrcommon::
vaddress &addr) throw (socket_exception) = 0;
255 void set(SERVER_OPTION opt,
bool val);
259 serversocket(
int fd);
261 int _accept_fd(ibrcommon::
vaddress &addr) throw (socket_exception);
267 virtual void up()
throw (socket_exception) = 0;
268 virtual void down()
throw (socket_exception) = 0;
270 virtual ssize_t recvfrom(
char *buf,
size_t buflen,
int flags,
ibrcommon::vaddress &addr)
throw (socket_exception);
271 virtual void sendto(
const char *buf,
size_t buflen,
int flags,
const ibrcommon::vaddress &addr)
throw (socket_exception);
286 virtual void up()
throw (socket_exception);
287 virtual void down()
throw (socket_exception);
290 const File _filename;
301 virtual void up()
throw (socket_exception);
302 virtual void down()
throw (socket_exception);
307 void bind(
const File &file)
throw (socket_exception);
310 const File _filename;
322 virtual void up()
throw (socket_exception);
323 virtual void down()
throw (socket_exception);
340 virtual void up()
throw (socket_exception);
341 virtual void down()
throw (socket_exception);
343 const vaddress& get_address()
const;
348 void bind(
const vaddress &addr)
throw (socket_exception);
364 virtual void up()
throw (socket_exception);
365 virtual void down()
throw (socket_exception);
367 const vaddress& get_address()
const;
370 void bind(
const vaddress &addr)
throw (socket_exception);
379 virtual void up()
throw (socket_exception);
380 virtual void down()
throw (socket_exception);
386 void mcast_op(
int optname,
const vaddress &group,
const vinterface &iface)
throw (socket_exception);