{
int ret, remain;
- LOG_TRACE("write buflen : %d, buf : %s\n", len, (char *)buf);
+ LOG_TRACE("write fd: %d, buflen : %d, buf : %s\n", fd, len, (char *)buf);
if (fd < 0) {
+ LOG_SEVERE("fd is corrupted : %d\n", fd);
return -1;
}
remain = len;
while (len > 0) {
- ret = write(fd, buf, remain);
+ ret = send(fd, buf, remain, 0);
if (ret < 0) {
+#ifdef _WIN32
+ errno = WSAGetLastError();
+ if (errno != WSAEWOULDBLOCK) {
+ LOG_SEVERE("write error: %d\n", errno);
+ return -1;
+ }
+#else
if (errno != EINTR && errno != EAGAIN) {
+ LOG_SEVERE("write error: %d\n", errno);
return -1;
}
+#endif
} else if (ret == 0) {
break;
} else {
LOG_SEVERE("client is null.\n");
return;
}
+
#ifndef __WIN32
if (ioctl(cli->client_fd, FIONREAD, &to_read_bytes) < 0) {
LOG_SEVERE("ioctl failed\n");