#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
+#include <errno.h>
#include <string.h>
#include <unistd.h>
return GSOCK_IOERR;
}
- GSocket_SetBlocking(sck, sck->m_blocking);
+ GSocket_SetNonBlocking(sck, sck->m_blocking);
GSocket_SetTimeout(sck, sck->m_timeout);
return GSOCK_NOERROR;
/* It is not a server */
sck->m_server = FALSE;
- GSocket_SetBlocking(sck, sck->m_blocking);
+ GSocket_SetNonBlocking(sck, sck->m_blocking);
GSocket_SetTimeout(sck, sck->m_timeout);
return GSOCK_NOERROR;
MASK_SIGNAL();
ret = recv(socket->m_fd, buffer, size, 0);
UNMASK_SIGNAL();
- if (ret == -1) {
+ if (ret == -1 && errno != EAGAIN) {
socket->m_error = GSOCK_IOERR;
return -1;
}
+ if (errno == EAGAIN) {
+ socket->m_error = GSOCK_TRYAGAIN;
+ return -1;
+ }
return ret;
}
MASK_SIGNAL();
ret = recvfrom(socket->m_fd, buffer, size, 0, &from, &fromlen);
UNMASK_SIGNAL();
- if (ret == -1) {
+ if (ret == -1 && errno != EAGAIN) {
socket->m_error = GSOCK_IOERR;
return -1;
}
+ if (errno == EAGAIN) {
+ socket->m_error = GSOCK_TRYAGAIN;
+ return -1;
+ }
/* Translate a system address into a GSocket address */
if (!socket->m_peer)
MASK_SIGNAL();
ret = send(socket->m_fd, buffer, size, 0);
UNMASK_SIGNAL();
- if (ret == -1) {
+ if (ret == -1 && errno != EAGAIN) {
socket->m_error = GSOCK_IOERR;
return -1;
}
+ if (errno == EAGAIN) {
+ socket->m_error = GSOCK_TRYAGAIN;
+ return -1;
+ }
return ret;
}
MASK_SIGNAL();
ret = sendto(socket->m_fd, buffer, size, 0, addr, len);
UNMASK_SIGNAL();
- if (ret == -1) {
- socket->m_error = GSOCK_IOERR;
- return -1;
- }
/* Frees memory allocated from _GAddress_translate_to */
free(addr);
+ if (ret == -1 && errno != EAGAIN) {
+ socket->m_error = GSOCK_IOERR;
+ return -1;
+ }
+ if (errno == EAGAIN) {
+ socket->m_error = GSOCK_TRYAGAIN;
+ return -1;
+ }
+
return ret;
}