{
int *p_fd = data;
int fd = *p_fd;
- *p_fd = -1;
- if (fd >= 0) close(fd);
+ *p_fd = INVALID_SOCKET;
+ if (fd != INVALID_SOCKET) close(fd);
}
int
efl_net_socket4(int domain, int type, int protocol, Eina_Bool close_on_exec)
{
- int fd = -1;
+ int fd = INVALID_SOCKET;
#ifdef SOCK_CLOEXEC
if (close_on_exec) type |= SOCK_CLOEXEC;
#endif
fd = socket(domain, type, protocol);
-#ifndef SOCK_CLOEXEC
+#if !defined(SOCK_CLOEXEC) && defined(FD_CLOEXEC)
EINA_THREAD_CLEANUP_PUSH(_cleanup_close, &fd);
- if (fd > 0)
+ if (fd != INVALID_SOCKET)
{
if (close_on_exec)
{
int errno_bkp = errno;
ERR("fcntl(%d, F_SETFD, FD_CLOEXEC): %s", fd, strerror(errno));
close(fd);
- fd = -1;
+ fd = INVALID_SOCKET;
errno = errno_bkp;
}
}
* under construction socket to a child process.
*/
d->sockfd = efl_net_socket4(d->addr->sa_family, d->type, d->protocol, EINA_TRUE);
- if (d->sockfd < 0)
+ if (d->sockfd == INVALID_SOCKET)
{
- d->error = errno;
- DBG("socket(%d, %d, %d) failed: %s", d->addr->sa_family, d->type, d->protocol, strerror(errno));
+ d->error = efl_net_socket_error_get();
+ DBG("socket(%d, %d, %d) failed: %s", d->addr->sa_family, d->type, d->protocol, eina_error_msg_get(d->error));
return;
}
if (setsockopt(d->sockfd, SOL_SOCKET, SO_BROADCAST, &enable, sizeof(enable)) == 0)
DBG("enabled SO_BROADCAST for socket=%d", d->sockfd);
else
- WRN("could not enable SO_BROADCAST for socket=%d: %s", d->sockfd, strerror(errno));
+ WRN("could not enable SO_BROADCAST for socket=%d: %s", d->sockfd, eina_error_msg_get(efl_net_socket_error_get()));
}
DBG("connecting fd=%d to %s", d->sockfd, buf);
r = connect(d->sockfd, d->addr, d->addrlen);
- if (r < 0)
+ if (r != 0)
{
int fd = d->sockfd;
- d->error = errno;
- d->sockfd = -1;
+ d->error = efl_net_socket_error_get();
+ d->sockfd = INVALID_SOCKET;
/* close() is a cancellation point, thus unset sockfd before
* closing, so the main thread _efl_net_connect_async_cancel()
* won't close it again.
*/
close(fd);
- DBG("connect(%d, %s) failed: %s", fd, buf, strerror(errno));
+ DBG("connect(%d, %s) failed: %s", fd, buf, eina_error_msg_get(d->error));
return;
}
#ifdef FD_CLOEXEC
/* if it wasn't a close on exec, release the socket to be passed to child */
- if ((!d->close_on_exec) && (d->sockfd >= 0))
+ if ((!d->close_on_exec) && (d->sockfd != INVALID_SOCKET))
{
int flags = fcntl(d->sockfd, F_GETFD);
if (flags < 0)
{
d->error = errno;
- ERR("fcntl(%d, F_GETFD): %s", d->sockfd, strerror(errno));
+ ERR("fcntl(%d, F_GETFD): %s", d->sockfd, eina_error_msg_get(d->error));
close(d->sockfd);
- d->sockfd = -1;
+ d->sockfd = INVALID_SOCKET;
}
else
{
if (fcntl(d->sockfd, F_SETFD, flags) < 0)
{
d->error = errno;
- ERR("fcntl(%d, F_SETFD, %#x): %s", d->sockfd, flags, strerror(errno));
+ ERR("fcntl(%d, F_SETFD, %#x): %s", d->sockfd, flags, eina_error_msg_get(d->error));
close(d->sockfd);
- d->sockfd = -1;
+ d->sockfd = INVALID_SOCKET;
}
}
}
_efl_net_connect_async_cancel(void *data, Ecore_Thread *thread EINA_UNUSED)
{
Efl_Net_Connect_Async_Data *d = data;
- if (d->sockfd >= 0) close(d->sockfd);
+ if (d->sockfd != INVALID_SOCKET) close(d->sockfd);
_efl_net_connect_async_data_free(d);
}
d->protocol = protocol;
memcpy(d->addr, addr, addrlen);
- d->sockfd = -1;
+ d->sockfd = INVALID_SOCKET;
d->error = 0;
return ecore_thread_run(_efl_net_connect_async_run,
static Eina_Error
_efl_net_ip_connect(const struct addrinfo *addr, int *sockfd)
{
- int fd = -1;
+ int fd = INVALID_SOCKET;
Eina_Error ret = 0;
/* always close-on-exec since it's not a point to pass an
* under construction socket to a child process.
*/
fd = efl_net_socket4(addr->ai_family, addr->ai_socktype, addr->ai_protocol, EINA_TRUE);
- if (fd < 0) ret = errno;
+ if (fd == INVALID_SOCKET) ret = efl_net_socket_error_get();
else
{
char buf[INET6_ADDRSTRLEN + sizeof("[]:65536")] = "";
(addr->ai_family == AF_INET) &&
(((const struct sockaddr_in *)addr->ai_addr)->sin_addr.s_addr == INADDR_BROADCAST))
{
+#ifdef _WIN32
+ DWORD enable = 1;
+#else
int enable = 1;
+#endif
if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &enable, sizeof(enable)) == 0)
DBG("enabled SO_BROADCAST for socket=%d", fd);
else
- WRN("could not enable SO_BROADCAST for socket=%d: %s", fd, strerror(errno));
+ WRN("could not enable SO_BROADCAST for socket=%d: %s", fd, eina_error_msg_get(efl_net_socket_error_get()));
}
r = connect(fd, addr->ai_addr, addr->ai_addrlen);
}
else
{
- ret = errno;
- DBG("couldn't connect fd=%d to %s: %s", fd, buf, strerror(errno));
+ ret = efl_net_socket_error_get();
+ DBG("couldn't connect fd=%d to %s: %s", fd, buf, eina_error_msg_get(ret));
close(fd);
}
EINA_THREAD_CLEANUP_POP(EINA_FALSE); /* we need sockfd on success */
DBG("couldn't resolve host='%s', port='%s': %s",
host, port, gai_strerror(r));
ret = EFL_NET_DIALER_ERROR_COULDNT_RESOLVE_HOST;
- *sockfd = -1;
+ *sockfd = INVALID_SOCKET;
}
else
{
s = send(fd, request, request_len, MSG_NOSIGNAL);
if (s != (ssize_t)request_len)
{
- if (s < 0)
- DBG("couldn't request connection to host=%s fd=%d socks4://%s:%s: %s", buf, fd, proxy_host, proxy_port, strerror(errno));
+ if (s == SOCKET_ERROR)
+ DBG("couldn't request connection to host=%s fd=%d socks4://%s:%s: %s", buf, fd, proxy_host, proxy_port, eina_error_msg_get(efl_net_socket_error_get()));
else
DBG("couldn't send proxy request: need %zu, did %zd", request_len, s);
}
s = recv(fd, &reply, sizeof(reply), MSG_NOSIGNAL);
if (s != sizeof(reply))
{
- if (s < 0)
- DBG("couldn't recv reply of connection to host=%s fd=%d socks4://%s:%s: %s", buf, fd, proxy_host, proxy_port, strerror(errno));
+ if (s == SOCKET_ERROR)
+ DBG("couldn't recv reply of connection to host=%s fd=%d socks4://%s:%s: %s", buf, fd, proxy_host, proxy_port, eina_error_msg_get(efl_net_socket_error_get()));
else
DBG("couldn't recv proxy reply: need %zu, did %zd", sizeof(reply), s);
}
static void
_efl_net_ip_connect_async_run_socks4a(Efl_Net_Ip_Connect_Async_Data *d, const char *host, const char *port, const char *proxy)
{
- int fd = -1;
+ int fd = INVALID_SOCKET;
char *str;
const char *proxy_user, *proxy_pass, *proxy_host, *proxy_port;
struct sockaddr_storage proxy_addr;
s = send(fd, request, request_len, MSG_NOSIGNAL);
if (s != (ssize_t)request_len)
{
- if (s < 0)
- DBG("couldn't send proxy request: %s", strerror(errno));
+ if (s == SOCKET_ERROR)
+ DBG("couldn't send proxy request: %s", eina_error_msg_get(efl_net_socket_error_get()));
else
DBG("couldn't send proxy request: need %zu, did %zd", request_len, s);
}
s = recv(fd, &reply, sizeof(reply), MSG_NOSIGNAL);
if (s != sizeof(reply))
{
- if (s < 0)
- DBG("couldn't recv proxy reply: %s", strerror(errno));
+ if (s == SOCKET_ERROR)
+ DBG("couldn't recv proxy reply: %s", eina_error_msg_get(efl_net_socket_error_get()));
else
DBG("couldn't recv proxy reply: need %zu, did %zd", sizeof(reply), s);
}
s = send(fd, msg, len, MSG_NOSIGNAL);
if (s != (ssize_t)len)
{
- if (s < 0)
- DBG("couldn't send user-password authentication to fd=%d %s://%s:%s: %s", fd, proxy_protocol, proxy_host, proxy_port, strerror(errno));
+ if (s == SOCKET_ERROR)
+ DBG("couldn't send user-password authentication to fd=%d %s://%s:%s: %s", fd, proxy_protocol, proxy_host, proxy_port, eina_error_msg_get(efl_net_socket_error_get()));
else
DBG("couldn't send user-password authentication: need %zu, did %zd", len, s);
}
s = recv(fd, &reply, sizeof(reply), MSG_NOSIGNAL);
if (s != (ssize_t)sizeof(reply))
{
- if (s < 0)
- DBG("couldn't recv user-password authentication reply from fd=%d %s://%s:%s: %s", fd, proxy_protocol, proxy_host, proxy_port, strerror(errno));
+ if (s == SOCKET_ERROR)
+ DBG("couldn't recv user-password authentication reply from fd=%d %s://%s:%s: %s", fd, proxy_protocol, proxy_host, proxy_port, eina_error_msg_get(efl_net_socket_error_get()));
else
DBG("couldn't recv user-password authentication reply: need %zu, did %zd", len, s);
}
s = send(fd, &greeting, sizeof(greeting), MSG_NOSIGNAL);
if (s != (ssize_t)sizeof(greeting))
{
- if (s < 0)
- DBG("couldn't request connection to host=%s fd=%d socks5://%s:%s: %s", buf, fd, proxy_host, proxy_port, strerror(errno));
+ if (s == SOCKET_ERROR)
+ DBG("couldn't request connection to host=%s fd=%d socks5://%s:%s: %s", buf, fd, proxy_host, proxy_port, eina_error_msg_get(efl_net_socket_error_get()));
else
DBG("couldn't send proxy request: need %zu, did %zd", sizeof(greeting), s);
}
s = recv(fd, &greeting_reply, sizeof(greeting_reply), MSG_NOSIGNAL);
if (s != sizeof(greeting_reply))
{
- if (s < 0)
- DBG("couldn't recv greeting reply of connection to host=%s fd=%d socks5://%s:%s: %s", buf, fd, proxy_host, proxy_port, strerror(errno));
+ if (s == SOCKET_ERROR)
+ DBG("couldn't recv greeting reply of connection to host=%s fd=%d socks5://%s:%s: %s", buf, fd, proxy_host, proxy_port, eina_error_msg_get(efl_net_socket_error_get()));
else
DBG("couldn't recv proxy reply: need %zu, did %zd", sizeof(greeting_reply), s);
}
s = send(fd, request, request_len, MSG_NOSIGNAL);
if (s != (ssize_t)request_len)
{
- if (s < 0)
- DBG("couldn't request connection to host=%s fd=%d socks5://%s:%s: %s", buf, fd, proxy_host, proxy_port, strerror(errno));
+ if (s == SOCKET_ERROR)
+ DBG("couldn't request connection to host=%s fd=%d socks5://%s:%s: %s", buf, fd, proxy_host, proxy_port, eina_error_msg_get(efl_net_socket_error_get()));
else
DBG("couldn't send proxy request: need %zu, did %zd", request_len, s);
}
s = recv(fd, &reply, sizeof(reply), MSG_NOSIGNAL);
if (s != sizeof(reply))
{
- if (s < 0)
- DBG("couldn't recv reply of connection to host=%s fd=%d socks5://%s:%s: %s", buf, fd, proxy_host, proxy_port, strerror(errno));
+ if (s == SOCKET_ERROR)
+ DBG("couldn't recv reply of connection to host=%s fd=%d socks5://%s:%s: %s", buf, fd, proxy_host, proxy_port, eina_error_msg_get(efl_net_socket_error_get()));
else
DBG("couldn't recv proxy reply: need %zu, did %zd", sizeof(reply), s);
}
s = recv(fd, &reply, sizeof(reply), MSG_NOSIGNAL);
if (s != sizeof(reply))
{
- if (s < 0)
- DBG("couldn't recv reply of connection to host=%s fd=%d socks5://%s:%s: %s", buf, fd, proxy_host, proxy_port, strerror(errno));
+ if (s == SOCKET_ERROR)
+ DBG("couldn't recv reply of connection to host=%s fd=%d socks5://%s:%s: %s", buf, fd, proxy_host, proxy_port, eina_error_msg_get(efl_net_socket_error_get()));
else
DBG("couldn't recv proxy reply: need %zu, did %zd", sizeof(reply), s);
}
static void
_efl_net_ip_connect_async_run_socks5h(Efl_Net_Ip_Connect_Async_Data *d, const char *host, const char *port, const char *proxy)
{
- int fd = -1;
+ int fd = INVALID_SOCKET;
char *str;
const char *proxy_user, *proxy_pass, *proxy_host, *proxy_port;
struct sockaddr_storage proxy_addr;
s = send(fd, &greeting, sizeof(greeting), MSG_NOSIGNAL);
if (s != (ssize_t)sizeof(greeting))
{
- if (s < 0)
- DBG("couldn't request connection to host=%s:%s fd=%d socks5h://%s:%s: %s", host, port, fd, proxy_host, proxy_port, strerror(errno));
+ if (s == SOCKET_ERROR)
+ DBG("couldn't request connection to host=%s:%s fd=%d socks5h://%s:%s: %s", host, port, fd, proxy_host, proxy_port, eina_error_msg_get(efl_net_socket_error_get()));
else
DBG("couldn't send proxy request: need %zu, did %zd", sizeof(greeting), s);
}
s = recv(fd, &greeting_reply, sizeof(greeting_reply), MSG_NOSIGNAL);
if (s != sizeof(greeting_reply))
{
- if (s < 0)
- DBG("couldn't recv greeting reply of connection to host=%s:%s fd=%d socks5h://%s:%s: %s", host, port, fd, proxy_host, proxy_port, strerror(errno));
+ if (s == SOCKET_ERROR)
+ DBG("couldn't recv greeting reply of connection to host=%s:%s fd=%d socks5h://%s:%s: %s", host, port, fd, proxy_host, proxy_port, eina_error_msg_get(efl_net_socket_error_get()));
else
DBG("couldn't recv proxy reply: need %zu, did %zd", sizeof(greeting_reply), s);
}
s = send(fd, request, request_len, MSG_NOSIGNAL);
if (s != (ssize_t)request_len)
{
- if (s < 0)
- DBG("couldn't request connection to host=%s:%s fd=%d socks5h://%s:%s: %s", host, port, fd, proxy_host, proxy_port, strerror(errno));
+ if (s == SOCKET_ERROR)
+ DBG("couldn't request connection to host=%s:%s fd=%d socks5h://%s:%s: %s", host, port, fd, proxy_host, proxy_port, eina_error_msg_get(efl_net_socket_error_get()));
else
DBG("couldn't send proxy request: need %zu, did %zd", request_len, s);
}
s = recv(fd, &reply, sizeof(reply), MSG_NOSIGNAL);
if (s != sizeof(reply))
{
- if (s < 0)
- DBG("couldn't recv reply of connection to host=%s:%s fd=%d socks5h://%s:%s: %s", host, port, fd, proxy_host, proxy_port, strerror(errno));
+ if (s == SOCKET_ERROR)
+ DBG("couldn't recv reply of connection to host=%s:%s fd=%d socks5h://%s:%s: %s", host, port, fd, proxy_host, proxy_port, eina_error_msg_get(efl_net_socket_error_get()));
else
DBG("couldn't recv proxy reply: need %zu, did %zd", sizeof(reply), s);
}
s = recv(fd, &ipv4, sizeof(ipv4), MSG_NOSIGNAL);
if (s != sizeof(ipv4))
{
- if (s < 0)
- DBG("couldn't recv ipv4 of connection to host=%s:%s fd=%d socks5h://%s:%s: %s", host, port, fd, proxy_host, proxy_port, strerror(errno));
+ if (s == SOCKET_ERROR)
+ DBG("couldn't recv ipv4 of connection to host=%s:%s fd=%d socks5h://%s:%s: %s", host, port, fd, proxy_host, proxy_port, eina_error_msg_get(efl_net_socket_error_get()));
else
DBG("couldn't recv proxy ipv4: need %zu, did %zd", sizeof(ipv4), s);
}
s = recv(fd, &ipv6, sizeof(ipv6), MSG_NOSIGNAL);
if (s != sizeof(ipv6))
{
- if (s < 0)
- DBG("couldn't recv ipv6 of connection to host=%s:%s fd=%d socks5h://%s:%s: %s", host, port, fd, proxy_host, proxy_port, strerror(errno));
+ if (s == SOCKET_ERROR)
+ DBG("couldn't recv ipv6 of connection to host=%s:%s fd=%d socks5h://%s:%s: %s", host, port, fd, proxy_host, proxy_port, eina_error_msg_get(efl_net_socket_error_get()));
else
DBG("couldn't recv proxy ipv6: need %zu, did %zd", sizeof(ipv6), s);
}
#ifdef FD_CLOEXEC
/* if it wasn't a close on exec, release the socket to be passed to child */
- if ((!d->close_on_exec) && (d->sockfd >= 0))
+ if ((!d->close_on_exec) && (d->sockfd != INVALID_SOCKET))
{
int flags = fcntl(d->sockfd, F_GETFD);
if (flags < 0)
d->error = errno;
ERR("fcntl(%d, F_GETFD): %s", d->sockfd, strerror(errno));
close(d->sockfd);
- d->sockfd = -1;
+ d->sockfd = INVALID_SOCKET;
}
else
{
d->error = errno;
ERR("fcntl(%d, F_SETFD, %#x): %s", d->sockfd, flags, strerror(errno));
close(d->sockfd);
- d->sockfd = -1;
+ d->sockfd = INVALID_SOCKET;
}
}
}
_efl_net_ip_connect_async_cancel(void *data, Ecore_Thread *thread EINA_UNUSED)
{
Efl_Net_Ip_Connect_Async_Data *d = data;
- if (d->sockfd >= 0) close(d->sockfd);
+ if (d->sockfd != INVALID_SOCKET) close(d->sockfd);
_efl_net_ip_connect_async_data_free(d);
}
d->type = type;
d->protocol = protocol;
- d->sockfd = -1;
+ d->sockfd = INVALID_SOCKET;
d->error = 0;
Eina_Bool efl_net_ip_port_fmt(char *buf, int buflen, const struct sockaddr *addr);
+/* allow windows and posix to use the same error comparison */
+#ifndef SOCKET_ERROR
+#define SOCKET_ERROR -1
+#endif
+#ifndef INVALID_SOCKET
+#define INVALID_SOCKET -1
+#endif
+
/**
* @brief splits an address in the format "host:port" in two
* null-terminated strings.
Efl_Net_Dialer_Http_Data *pd = efl_data_scope_get(o, MY_CLASS);
pd->fd = efl_net_socket4(addr->family, addr->socktype, addr->protocol, pd->close_on_exec);
- if (pd->fd < 0)
+ if (pd->fd == INVALID_SOCKET)
ERR("could not create curl socket family=%d, type=%d, protocol=%d",
addr->family, addr->socktype, addr->protocol);
else
EINA_SAFETY_ON_TRUE_RETURN_VAL(efl_io_closer_closed_get(o), EBADF);
- pd->fd = -1;
+ pd->fd = INVALID_SOCKET;
if (pd->in_curl_callback)
{
pd->close_on_exec = close_on_exec;
- if (pd->fd < 0) return EINA_TRUE; /* postpone until _efl_net_dialer_http_socket_open */
+ if (pd->fd == INVALID_SOCKET) return EINA_TRUE; /* postpone until _efl_net_dialer_http_socket_open */
flags = fcntl(pd->fd, F_GETFD);
if (flags < 0)
int client = accept(fd, addr, addrlen);
if (client < 0) return client;
+#ifdef FD_CLOEXEC
if (close_on_exec)
{
if (fcntl(client, F_SETFD, FD_CLOEXEC) < 0)
return -1;
}
}
+#endif
+
return client;
#endif
}
{
efl_loop_fd_set(efl_super(o, MY_CLASS), fd);
- if (fd >= 0)
+ if (fd != INVALID_SOCKET)
{
/* apply postponed values */
efl_net_server_fd_close_on_exec_set(o, pd->close_on_exec);
EOLIAN static Eina_Bool
_efl_net_server_fd_close_on_exec_set(Eo *o, Efl_Net_Server_Fd_Data *pd, Eina_Bool close_on_exec)
{
+#ifdef FD_CLOEXEC
int flags, fd;
Eina_Bool old = pd->close_on_exec;
+#endif
pd->close_on_exec = close_on_exec;
+#ifdef FD_CLOEXEC
fd = efl_loop_fd_get(o);
- if (fd < 0) return EINA_TRUE; /* postpone until fd_set() */
+ if (fd == INVALID_SOCKET) return EINA_TRUE; /* postpone until fd_set() */
flags = fcntl(fd, F_GETFD);
if (flags < 0)
pd->close_on_exec = old;
return EINA_FALSE;
}
+#endif
return EINA_TRUE;
}
EOLIAN static Eina_Bool
_efl_net_server_fd_close_on_exec_get(Eo *o, Efl_Net_Server_Fd_Data *pd)
{
+#ifdef FD_CLOEXEC
int flags, fd;
fd = efl_loop_fd_get(o);
- if (fd < 0) return pd->close_on_exec;
+ if (fd == INVALID_SOCKET) return pd->close_on_exec;
/* if there is a fd, always query it directly as it may be modified
* elsewhere by nasty users.
}
pd->close_on_exec = !!(flags & FD_CLOEXEC); /* sync */
+#endif
return pd->close_on_exec;
}
pd->reuse_address = reuse_address;
fd = efl_loop_fd_get(o);
- if (fd < 0) return EINA_TRUE; /* postpone until fd_set() */
+ if (fd == INVALID_SOCKET) return EINA_TRUE; /* postpone until fd_set() */
value = reuse_address;
- if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &value, sizeof(value)) < 0)
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &value, sizeof(value)) != 0)
{
ERR("setsockopt(%d, SOL_SOCKET, SO_REUSEADDR, %d): %s",
- fd, value, strerror(errno));
+ fd, value, eina_error_msg_get(efl_net_socket_error_get()));
pd->reuse_address = old;
return EINA_FALSE;
}
socklen_t valuelen;
fd = efl_loop_fd_get(o);
- if (fd < 0) return pd->reuse_address;
+ if (fd == INVALID_SOCKET) return pd->reuse_address;
/* if there is a fd, always query it directly as it may be modified
* elsewhere by nasty users.
*/
valuelen = sizeof(value);
- if (getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &value, &valuelen) < 0)
+ if (getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &value, &valuelen) != 0)
{
ERR("getsockopt(%d, SOL_SOCKET, SO_REUSEADDR): %s",
- fd, strerror(errno));
+ fd, eina_error_msg_get(efl_net_socket_error_get()));
return EINA_FALSE;
}
EOLIAN static Eina_Bool
_efl_net_server_fd_reuse_port_set(Eo *o, Efl_Net_Server_Fd_Data *pd, Eina_Bool reuse_port)
{
+#ifdef SO_REUSEPORT
int value, fd;
Eina_Bool old = pd->reuse_port;
+#endif
pd->reuse_port = reuse_port;
+#ifdef SO_REUSEPORT
fd = efl_loop_fd_get(o);
- if (fd < 0) return EINA_TRUE; /* postpone until fd_set() */
+ if (fd == INVALID_SOCKET) return EINA_TRUE; /* postpone until fd_set() */
-#ifdef SO_REUSEPORT
value = reuse_port;
- if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &value, sizeof(value)) < 0)
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &value, sizeof(value)) != 0)
{
ERR("setsockopt(%d, SOL_SOCKET, SO_REUSEPORT, %d): %s",
- fd, value, strerror(errno));
+ fd, value, eina_error_msg_get(efl_net_socket_error_get()));
pd->reuse_port = old;
return EINA_FALSE;
}
- return EINA_TRUE;
-#else
- pd->reuse_port = EINA_FALSE;
- return EINA_FALSE;
#endif
+
+ return EINA_TRUE;
}
EOLIAN static Eina_Bool
_efl_net_server_fd_reuse_port_get(Eo *o, Efl_Net_Server_Fd_Data *pd)
{
+#ifdef SO_REUSEPORT
int value = 0, fd;
socklen_t valuelen;
fd = efl_loop_fd_get(o);
- if (fd < 0) return pd->reuse_port;
+ if (fd == INVALID_SOCKET) return pd->reuse_port;
/* if there is a fd, always query it directly as it may be modified
* elsewhere by nasty users.
*/
-#ifdef SO_REUSEPORT
valuelen = sizeof(value);
- if (getsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &value, &valuelen) < 0)
+ if (getsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &value, &valuelen) != 0)
{
ERR("getsockopt(%d, SOL_SOCKET, SO_REUSEPORT): %s",
- fd, strerror(errno));
+ fd, eina_error_msg_get(efl_net_socket_error_get()));
return EINA_FALSE;
}
pd->reuse_port = !!value; /* sync */
- return pd->reuse_port;
-#else
- return EINA_FALSE;
#endif
+
+ return pd->reuse_port;
}
EOLIAN static void
efl_net_server_fd_close_on_exec_get(o));
if (client < 0)
{
- Eina_Error err = errno;
- ERR("accept(%d): %s", fd, strerror(errno));
+ Eina_Error err = efl_net_socket_error_get();
+ ERR("accept(%d): %s", fd, eina_error_msg_get(err));
efl_event_callback_call(o, EFL_NET_SERVER_EVENT_ERROR, &err);
return;
}
fd = efl_net_socket4(addr->ai_family, addr->ai_socktype, addr->ai_protocol,
efl_net_server_fd_close_on_exec_get(o));
- if (fd < 0)
+ if (fd == INVALID_SOCKET)
{
+ err = efl_net_socket_error_get();
ERR("socket(%d, %d, %d): %s",
addr->ai_family, addr->ai_socktype, addr->ai_protocol,
- strerror(errno));
- return errno;
+ eina_error_msg_get(err));
+ return err;
}
efl_loop_fd_set(o, fd);
}
r = bind(fd, addr->ai_addr, addrlen);
- if (r < 0)
+ if (r != 0)
{
- err = errno;
+ err = efl_net_socket_error_get();
efl_net_ip_port_fmt(buf, sizeof(buf), addr->ai_addr);
- DBG("bind(%d, %s): %s", fd, buf, strerror(errno));
+ DBG("bind(%d, %s): %s", fd, buf, eina_error_msg_get(err));
goto error;
}
r = listen(fd, 0);
- if (r < 0)
+ if (r != 0)
{
- err = errno;
- DBG("listen(%d): %s", fd, strerror(errno));
+ err = efl_net_socket_error_get();
+ DBG("listen(%d): %s", fd, eina_error_msg_get(err));
goto error;
}
if (getsockname(fd, addr->ai_addr, &addrlen) != 0)
{
- ERR("getsockname(%d): %s", fd, strerror(errno));
+ err = efl_net_socket_error_get();
+ ERR("getsockname(%d): %s", fd, eina_error_msg_get(err));
goto error;
}
else if (efl_net_ip_port_fmt(buf, sizeof(buf), addr->ai_addr))
char str[INET6_ADDRSTRLEN + sizeof("[]:65536")] = "";
addrlen = sizeof(addr);
- if (getpeername(client_fd, (struct sockaddr *)&addr, &addrlen) < 0)
- ERR("getpeername(%d): %s", client_fd, strerror(errno));
+ if (getpeername(client_fd, (struct sockaddr *)&addr, &addrlen) != 0)
+ ERR("getpeername(%d): %s", client_fd, eina_error_msg_get(efl_net_socket_error_get()));
else
efl_net_ip_port_fmt(str, sizeof(str), (struct sockaddr *)&addr);
EOLIAN void
_efl_net_server_tcp_ipv6_only_set(Eo *o, Efl_Net_Server_Tcp_Data *pd, Eina_Bool ipv6_only)
{
+#ifdef IPV6_V6ONLY
Eina_Bool old = pd->ipv6_only;
int fd = efl_loop_fd_get(o);
+#ifdef _WIN32
+ DWORD value = ipv6_only;
+#else
int value = ipv6_only;
+#endif
+#endif
pd->ipv6_only = ipv6_only;
- if (fd < 0) return;
+#ifdef IPV6_V6ONLY
+ if (fd == INVALID_SOCKET) return;
if (efl_net_server_fd_family_get(o) != AF_INET6) return;
-#ifdef IPV6_V6ONLY
- if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &value, sizeof(value)) < 0)
+ if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &value, sizeof(value)) != 0)
{
- ERR("could not set socket=%d IPV6_V6ONLY=%d: %s", fd, value, strerror(errno));
+ ERR("could not set socket=%d IPV6_V6ONLY=%d: %s", fd, value, eina_error_msg_get(efl_net_socket_error_get()));
pd->ipv6_only = old;
}
#endif
{
#ifdef IPV6_V6ONLY
int fd = efl_loop_fd_get(o);
+#ifdef _WIN32
+ DWORD value = 0;
+ int valuelen;
+#else
int value = 0;
- socklen_t size = sizeof(value);
+ socklen_t valuelen;
+#endif
- if (fd < 0) goto end;
+ if (fd == INVALID_SOCKET) goto end;
if (efl_net_server_fd_family_get(o) != AF_INET6) goto end;
- if (getsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &value, &size) < 0)
+ valuelen = sizeof(value);
+ if (getsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &value, &valuelen) != 0)
{
- WRN("getsockopt(%d, IPPROTO_IPV6, IPV6_V6ONLY): %s", fd, strerror(errno));
+ WRN("getsockopt(%d, IPPROTO_IPV6, IPV6_V6ONLY): %s", fd, eina_error_msg_get(efl_net_socket_error_get()));
goto end;
}
pd->ipv6_only = !!value;
fd = efl_net_socket4(addr->ai_family, addr->ai_socktype, addr->ai_protocol,
efl_net_server_fd_close_on_exec_get(o));
- if (fd < 0)
+ if (fd == INVALID_SOCKET)
{
+ err = efl_net_socket_error_get();
ERR("socket(%d, %d, %d): %s",
addr->ai_family, addr->ai_socktype, addr->ai_protocol,
- strerror(errno));
- return errno;
+ eina_error_msg_get(err));
+ return err;
}
efl_loop_fd_set(o, fd);
efl_net_server_udp_dont_route_set(o, pd->dont_route);
r = bind(fd, addr->ai_addr, addrlen);
- if (r < 0)
+ if (r != 0)
{
- err = errno;
+ err = efl_net_socket_error_get();
efl_net_ip_port_fmt(buf, sizeof(buf), addr->ai_addr);
- DBG("bind(%d, %s): %s", fd, buf, strerror(errno));
+ DBG("bind(%d, %s): %s", fd, buf, eina_error_msg_get(err));
goto error;
}
if (getsockname(fd, addr->ai_addr, &addrlen) != 0)
{
- ERR("getsockname(%d): %s", fd, strerror(errno));
+ err = efl_net_socket_error_get();
+ ERR("getsockname(%d): %s", fd, eina_error_msg_get(err));
goto error;
}
else if (efl_net_ip_port_fmt(buf, sizeof(buf), addr->ai_addr))
EOLIAN void
_efl_net_server_udp_ipv6_only_set(Eo *o, Efl_Net_Server_Udp_Data *pd, Eina_Bool ipv6_only)
{
+#ifdef IPV6_V6ONLY
Eina_Bool old = pd->ipv6_only;
int fd = efl_loop_fd_get(o);
+#ifdef _WIN32
+ DWORD value = ipv6_only;
+#else
int value = ipv6_only;
+#endif
+#endif
pd->ipv6_only = ipv6_only;
- if (fd < 0) return;
+#ifdef IPV6_V6ONLY
+ if (fd == INVALID_SOCKET) return;
if (efl_net_server_fd_family_get(o) != AF_INET6) return;
-#ifdef IPV6_V6ONLY
- if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &value, sizeof(value)) < 0)
+ if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &value, sizeof(value)) != 0)
{
- ERR("could not set socket=%d IPV6_V6ONLY=%d: %s", fd, value, strerror(errno));
+ ERR("could not set socket=%d IPV6_V6ONLY=%d: %s", fd, value, eina_error_msg_get(efl_net_socket_error_get()));
pd->ipv6_only = old;
}
#endif
{
#ifdef IPV6_V6ONLY
int fd = efl_loop_fd_get(o);
+#ifdef _WIN32
+ DWORD value = 0;
+ int valuelen;
+#else
int value = 0;
- socklen_t size = sizeof(value);
+ socklen_t valuelen;
+#endif
- if (fd < 0) goto end;
+ if (fd == INVALID_SOCKET) goto end;
if (efl_net_server_fd_family_get(o) != AF_INET6) goto end;
- if (getsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &value, &size) < 0)
+ valuelen = sizeof(value);
+ if (getsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &value, &valuelen) != 0)
{
- WRN("getsockopt(%d, IPPROTO_IPV6, IPV6_V6ONLY): %s", fd, strerror(errno));
+ WRN("getsockopt(%d, IPPROTO_IPV6, IPV6_V6ONLY): %s", fd, eina_error_msg_get(efl_net_socket_error_get()));
goto end;
}
pd->ipv6_only = !!value;
pd->dont_route = dont_route;
- if (fd < 0) return EINA_TRUE;
+ if (fd == INVALID_SOCKET) return EINA_TRUE;
if (setsockopt(fd, SOL_SOCKET, SO_DONTROUTE, &value, sizeof(value)) != 0)
{
#endif
socklen_t valuelen;
- if (fd < 0) return pd->dont_route;
+ if (fd == INVALID_SOCKET) return pd->dont_route;
/* if there is a fd, always query it directly as it may be modified
* elsewhere by nasty users.
{
Efl_Net_Server_Udp_Client_Packet *pkt;
- pd->fd = -1;
+ pd->fd = INVALID_SOCKET;
EINA_INLIST_FREE(pd->packets, pkt)
{
pd->packets = eina_inlist_remove(pd->packets, EINA_INLIST_GET(pkt));
ssize_t r;
EINA_SAFETY_ON_NULL_RETURN_VAL(ro_slice, EINVAL);
- if (pd->fd < 0) goto error;
+ if (pd->fd == INVALID_SOCKET) goto error;
do
{
EOLIAN static void
_efl_net_server_udp_client_efl_io_reader_can_read_set(Eo *o, Efl_Net_Server_Udp_Client_Data *pd, Eina_Bool can_read)
{
- EINA_SAFETY_ON_TRUE_RETURN(pd->fd < 0);
+ EINA_SAFETY_ON_TRUE_RETURN(pd->fd == INVALID_SOCKET);
if (pd->can_read == can_read) return;
pd->can_read = can_read;
efl_event_callback_call(o, EFL_IO_READER_EVENT_CAN_READ_CHANGED, NULL);
EOLIAN static void
_efl_net_server_udp_client_efl_io_reader_eos_set(Eo *o, Efl_Net_Server_Udp_Client_Data *pd, Eina_Bool is_eos)
{
- EINA_SAFETY_ON_TRUE_RETURN(pd->fd < 0);
+ EINA_SAFETY_ON_TRUE_RETURN(pd->fd == INVALID_SOCKET);
if (pd->eos == is_eos) return;
pd->eos = is_eos;
if (is_eos)
EOLIAN static void
_efl_net_server_udp_client_efl_io_writer_can_write_set(Eo *o, Efl_Net_Server_Udp_Client_Data *pd, Eina_Bool can_write)
{
- EINA_SAFETY_ON_TRUE_RETURN(pd->fd < 0);
+ EINA_SAFETY_ON_TRUE_RETURN(pd->fd == INVALID_SOCKET);
if (pd->can_write == can_write) return;
pd->can_write = can_write;
efl_event_callback_call(o, EFL_IO_WRITER_EVENT_CAN_WRITE_CHANGED, NULL);
EOLIAN static Eina_Bool
_efl_net_server_udp_client_efl_io_closer_closed_get(Eo *o EINA_UNUSED, Efl_Net_Server_Udp_Client_Data *pd)
{
- return pd->fd < 0;
+ return pd->fd == INVALID_SOCKET;
}
EOLIAN static void
EOLIAN static void
_efl_net_socket_fd_efl_loop_fd_fd_set(Eo *o, Efl_Net_Socket_Fd_Data *pd, int fd)
{
- if ((pd->family == AF_UNSPEC) && (fd >= 0))
+ if ((pd->family == AF_UNSPEC) && (fd != INVALID_SOCKET))
{
struct sockaddr_storage addr;
socklen_t addrlen = sizeof(addr);
- if (getsockname(fd, (struct sockaddr *)&addr, &addrlen) < 0)
+ if (getsockname(fd, (struct sockaddr *)&addr, &addrlen) != 0)
ERR("getsockname(%d): %s", fd, eina_error_msg_get(efl_net_socket_error_get()));
else
efl_net_socket_fd_family_set(o, addr.ss_family);
efl_loop_fd_set(efl_super(o, MY_CLASS), fd);
- if (fd >= 0) _efl_net_socket_fd_set(o, pd, fd);
+ if (fd != INVALID_SOCKET) _efl_net_socket_fd_set(o, pd, fd);
else _efl_net_socket_fd_unset(o);
}
ssize_t r;
EINA_SAFETY_ON_NULL_RETURN_VAL(rw_slice, EINVAL);
- if (fd < 0) goto error;
+ if (fd == INVALID_SOCKET) goto error;
do
{
r = recv(fd, rw_slice->mem, rw_slice->len, 0);
- if (r < 0)
+ if (r == SOCKET_ERROR)
{
Eina_Error err = efl_net_socket_error_get();
return err;
}
}
- while (r < 0);
+ while (r == SOCKET_ERROR);
rw_slice->len = r;
efl_io_reader_can_read_set(o, EINA_FALSE); /* wait Efl.Loop.Fd "read" */
ssize_t r;
EINA_SAFETY_ON_NULL_RETURN_VAL(ro_slice, EINVAL);
- if (fd < 0) goto error;
+ if (fd == INVALID_SOCKET) goto error;
do
{
r = send(fd, ro_slice->mem, ro_slice->len, 0);
- if (r < 0)
+ if (r == SOCKET_ERROR)
{
Eina_Error err = efl_net_socket_error_get();
return err;
}
}
- while (r < 0);
+ while (r == SOCKET_ERROR);
if (remaining)
{
{
efl_loop_fd_set(efl_super(o, MY_CLASS), fd);
- if (fd >= 0)
+ if (fd != INVALID_SOCKET)
{
struct sockaddr_storage addr;
socklen_t addrlen;
if (family == AF_UNSPEC) return;
addrlen = sizeof(addr);
- if (getsockname(fd, (struct sockaddr *)&addr, &addrlen) < 0)
- ERR("getsockname(%d): %s", fd, strerror(errno));
+ if (getsockname(fd, (struct sockaddr *)&addr, &addrlen) != 0)
+ ERR("getsockname(%d): %s", fd, eina_error_msg_get(efl_net_socket_error_get()));
else
{
char str[INET6_ADDRSTRLEN + sizeof("[]:65536")];
}
addrlen = sizeof(addr);
- if (getpeername(fd, (struct sockaddr *)&addr, &addrlen) < 0)
- ERR("getpeername(%d): %s", fd, strerror(errno));
+ if (getpeername(fd, (struct sockaddr *)&addr, &addrlen) != 0)
+ ERR("getpeername(%d): %s", fd, eina_error_msg_get(efl_net_socket_error_get()));
else
{
char str[INET6_ADDRSTRLEN + sizeof("[]:65536")];
EOLIAN static Eina_Bool
_efl_net_socket_tcp_keep_alive_set(Eo *o, Efl_Net_Socket_Tcp_Data *pd, Eina_Bool keep_alive)
{
- int value, fd;
+ int fd;
Eina_Bool old = pd->keep_alive;
+#ifdef _WIN32
+ DWORD value;
+#else
+ int value;
+#endif
pd->keep_alive = keep_alive;
fd = efl_loop_fd_get(o);
- if (fd < 0) return EINA_TRUE; /* postpone until fd_set() */
+ if (fd == INVALID_SOCKET) return EINA_TRUE; /* postpone until fd_set() */
value = keep_alive;
- if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &value, sizeof(value)) < 0)
+ if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &value, sizeof(value)) != 0)
{
ERR("setsockopt(%d, SOL_SOCKET, SO_KEEPALIVE, %d): %s",
- fd, value, strerror(errno));
+ fd, value, eina_error_msg_get(efl_net_socket_error_get()));
pd->keep_alive = old;
return EINA_FALSE;
}
EOLIAN static Eina_Bool
_efl_net_socket_tcp_keep_alive_get(Eo *o, Efl_Net_Socket_Tcp_Data *pd)
{
- int value = 0, fd;
+ int fd;
+#ifdef _WIN32
+ DWORD value = 0;
+ int valuelen;
+#else
+ int value = 0;
socklen_t valuelen;
+#endif
fd = efl_loop_fd_get(o);
- if (fd < 0) return pd->keep_alive;
+ if (fd == INVALID_SOCKET) return pd->keep_alive;
/* if there is a fd, always query it directly as it may be modified
* elsewhere by nasty users.
*/
valuelen = sizeof(value);
- if (getsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &value, &valuelen) < 0)
+ if (getsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &value, &valuelen) != 0)
{
ERR("getsockopt(%d, SOL_SOCKET, SO_KEEPALIVE): %s",
- fd, strerror(errno));
+ fd, eina_error_msg_get(efl_net_socket_error_get()));
return EINA_FALSE;
}
EOLIAN static Eina_Bool
_efl_net_socket_tcp_no_delay_set(Eo *o, Efl_Net_Socket_Tcp_Data *pd, Eina_Bool no_delay)
{
- int value, fd;
+ int fd;
Eina_Bool old = pd->no_delay;
+#ifdef _WIN32
+ BOOL value;
+#else
+ int value;
+#endif
pd->no_delay = no_delay;
fd = efl_loop_fd_get(o);
- if (fd < 0) return EINA_TRUE; /* postpone until fd_set() */
+ if (fd == INVALID_SOCKET) return EINA_TRUE; /* postpone until fd_set() */
value = no_delay;
- if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &value, sizeof(value)) < 0)
+ if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &value, sizeof(value)) != 0)
{
ERR("setsockopt(%d, IPPROTO_TCP, TCP_NODELAY, %d): %s",
- fd, value, strerror(errno));
+ fd, value, eina_error_msg_get(efl_net_socket_error_get()));
pd->no_delay = old;
return EINA_FALSE;
}
EOLIAN static Eina_Bool
_efl_net_socket_tcp_no_delay_get(Eo *o, Efl_Net_Socket_Tcp_Data *pd)
{
- int value = 0, fd;
+ int fd;
+#ifdef _WIN32
+ BOOL value;
+ int valuelen;
+#else
+ int value;
socklen_t valuelen;
+#endif
fd = efl_loop_fd_get(o);
- if (fd < 0) return pd->no_delay;
+ if (fd == INVALID_SOCKET) return pd->no_delay;
/* if there is a fd, always query it directly as it may be modified
* elsewhere by nasty users.
*/
valuelen = sizeof(value);
- if (getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &value, &valuelen) < 0)
+ if (getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &value, &valuelen) != 0)
{
ERR("getsockopt(%d, IPPROTO_TCP, TCP_NODELAY): %s",
- fd, strerror(errno));
+ fd, eina_error_msg_get(efl_net_socket_error_get()));
return EINA_FALSE;
}
pd->cork = cork;
fd = efl_loop_fd_get(o);
- if (fd < 0) return EINA_TRUE; /* postpone until fd_set() */
+ if (fd == INVALID_SOCKET) return EINA_TRUE; /* postpone until fd_set() */
value = cork;
- if (setsockopt(fd, IPPROTO_TCP, option, &value, sizeof(value)) < 0)
+ if (setsockopt(fd, IPPROTO_TCP, option, &value, sizeof(value)) != 0)
{
ERR("setsockopt(%d, IPPROTO_TCP, 0x%x, %d): %s",
- fd, option, value, strerror(errno));
+ fd, option, value, eina_error_msg_get(efl_net_socket_error_get()));
pd->cork = old;
return EINA_FALSE;
}
option = _cork_option_get();
if (EINA_UNLIKELY(option < 0))
{
- ERR("Could not find a TCP_CORK equivalent on your system");
+ WRN("Could not find a TCP_CORK equivalent on your system");
return EINA_FALSE;
}
fd = efl_loop_fd_get(o);
- if (fd < 0) return pd->cork;
+ if (fd == INVALID_SOCKET) return pd->cork;
/* if there is a fd, always query it directly as it may be modified
* elsewhere by nasty users.
*/
valuelen = sizeof(value);
- if (getsockopt(fd, IPPROTO_TCP, option, &value, &valuelen) < 0)
+ if (getsockopt(fd, IPPROTO_TCP, option, &value, &valuelen) != 0)
{
ERR("getsockopt(%d, IPPROTO_TCP, 0x%x): %s",
- fd, option, strerror(errno));
+ fd, option, eina_error_msg_get(efl_net_socket_error_get()));
return EINA_FALSE;
}
{
efl_loop_fd_set(efl_super(o, MY_CLASS), fd);
- if (fd >= 0)
+ if (fd != INVALID_SOCKET)
{
struct sockaddr_storage addr;
socklen_t addrlen;
if (family == AF_UNSPEC) return;
addrlen = sizeof(addr);
- if (getsockname(fd, (struct sockaddr *)&addr, &addrlen) < 0)
- ERR("getsockname(%d): %s", fd, strerror(errno));
+ if (getsockname(fd, (struct sockaddr *)&addr, &addrlen) != 0)
+ ERR("getsockname(%d): %s", fd, eina_error_msg_get(efl_net_socket_error_get()));
else
{
char str[INET6_ADDRSTRLEN + sizeof("[]:65536")];
}
addrlen = sizeof(addr);
- if (getpeername(fd, (struct sockaddr *)&addr, &addrlen) < 0)
- ERR("getpeername(%d): %s", fd, strerror(errno));
+ if (getpeername(fd, (struct sockaddr *)&addr, &addrlen) != 0)
+ ERR("getpeername(%d): %s", fd, eina_error_msg_get(efl_net_socket_error_get()));
else
{
char str[INET6_ADDRSTRLEN + sizeof("[]:65536")];
pd->cork = cork;
fd = efl_loop_fd_get(o);
- if (fd < 0) return EINA_TRUE; /* postpone until fd_set() */
+ if (fd == INVALID_SOCKET) return EINA_TRUE; /* postpone until fd_set() */
value = cork;
- if (setsockopt(fd, IPPROTO_UDP, option, &value, sizeof(value)) < 0)
+ if (setsockopt(fd, IPPROTO_UDP, option, &value, sizeof(value)) != 0)
{
ERR("setsockopt(%d, IPPROTO_UDP, 0x%x, %d): %s",
- fd, option, value, strerror(errno));
+ fd, option, value, eina_error_msg_get(efl_net_socket_error_get()));
pd->cork = old;
return EINA_FALSE;
}
option = _cork_option_get();
if (EINA_UNLIKELY(option < 0))
{
- ERR("Could not find a UDP_CORK equivalent on your system");
+ WRN("Could not find a UDP_CORK equivalent on your system");
return EINA_FALSE;
}
fd = efl_loop_fd_get(o);
- if (fd < 0) return pd->cork;
+ if (fd == INVALID_SOCKET) return pd->cork;
/* if there is a fd, always query it directly as it may be modified
* elsewhere by nasty users.
*/
valuelen = sizeof(value);
- if (getsockopt(fd, IPPROTO_UDP, option, &value, &valuelen) < 0)
+ if (getsockopt(fd, IPPROTO_UDP, option, &value, &valuelen) != 0)
{
ERR("getsockopt(%d, IPPROTO_UDP, 0x%x): %s",
- fd, option, strerror(errno));
+ fd, option, eina_error_msg_get(efl_net_socket_error_get()));
return EINA_FALSE;
}
pd->dont_route = dont_route;
- if (fd < 0) return EINA_TRUE;
+ if (fd == INVALID_SOCKET) return EINA_TRUE;
if (setsockopt(fd, SOL_SOCKET, SO_DONTROUTE, &value, sizeof(value)) != 0)
{
#endif
socklen_t valuelen;
- if (fd < 0) return pd->dont_route;
+ if (fd == INVALID_SOCKET) return pd->dont_route;
/* if there is a fd, always query it directly as it may be modified
* elsewhere by nasty users.