#include "sensor_log.h"
+#define SOCK_TIMEOUT 3
+
using namespace ipc;
static bool set_close_on_exec(int fd)
bool socket::connect(void)
{
- const int TIMEOUT = 3;
sockaddr_un addr;
fd_set write_fds;
FD_ZERO(&write_fds);
return false;
}
- if (!select_fds(m_sock_fd, NULL, &write_fds, TIMEOUT)) {
+ if (!select_fds(m_sock_fd, NULL, &write_fds, SOCK_TIMEOUT)) {
_E("Failed to select for socket[%d]", m_sock_fd);
close();
return false;
ssize_t socket::send(const void *buffer, size_t size, bool select) const
{
if (select) {
- const int TIMEOUT = 1;
fd_set write_fds;
FD_ZERO(&write_fds);
FD_SET(m_sock_fd, &write_fds);
- if (!select_fds(m_sock_fd, NULL, &write_fds, TIMEOUT)) {
+ if (!select_fds(m_sock_fd, NULL, &write_fds, SOCK_TIMEOUT)) {
_E("Failed to send message(timeout)");
return 0;
}
ssize_t socket::recv(void* buffer, size_t size, bool select) const
{
if (select) {
- const int TIMEOUT = 1;
fd_set read_fds;
FD_ZERO(&read_fds);
FD_SET(m_sock_fd, &read_fds);
- if (!select_fds(m_sock_fd, &read_fds, NULL, TIMEOUT)) {
+ if (!select_fds(m_sock_fd, &read_fds, NULL, SOCK_TIMEOUT)) {
_E("Failed to receive message(timeout)");
return 0;
}