Commit 7fac60649dc8e565bcc2fb4c0ca5519f87a5ff52
1 parent
faa3a30b
Using send
Showing
1 changed file
with
2 additions
and
2 deletions
epoll4.c
@@ -142,7 +142,7 @@ void server_run() { | @@ -142,7 +142,7 @@ void server_run() { | ||
142 | printf("[+] data: %s\n", buf); | 142 | printf("[+] data: %s\n", buf); |
143 | n = 0; | 143 | n = 0; |
144 | while (n != strlen(buf)) { | 144 | while (n != strlen(buf)) { |
145 | - int rv = write(events[i].data.fd, buf + n, strlen(buf) - n); | 145 | + int rv = send(events[i].data.fd, buf + n, strlen(buf) - n, MSG_NOSIGNAL); |
146 | if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) | 146 | if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) |
147 | continue; // FIXME: busy waiting - should wait using epoll | 147 | continue; // FIXME: busy waiting - should wait using epoll |
148 | if (rv == -1) | 148 | if (rv == -1) |
@@ -192,7 +192,7 @@ void client_run() { | @@ -192,7 +192,7 @@ void client_run() { | ||
192 | n = 0; | 192 | n = 0; |
193 | while (n != c) { | 193 | while (n != c) { |
194 | errno = 0; | 194 | errno = 0; |
195 | - int rv = write(sockfd, buf + n, c - n); | 195 | + int rv = send(sockfd, buf + n, c - n, MSG_NOSIGNAL); |
196 | if (rv == -1 && (errno == EINTR)) | 196 | if (rv == -1 && (errno == EINTR)) |
197 | continue; | 197 | continue; |
198 | if (rv == -1) | 198 | if (rv == -1) |