mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-03 13:28:44 +00:00
Use sendto on Mac too
This commit is contained in:
1 parent
bb72b2494d
commit
ebda2cb100
2 files changed
+2
-12
No files matched your search
+1
-6
@@ -3003,16 +3003,11 @@ static void iolog(struct mg_connection *c, char *buf, long n, bool r) {
|
|||||||
|
|
||||||
static long mg_sock_send(struct mg_connection *c, const void *buf, size_t len) {
|
static long mg_sock_send(struct mg_connection *c, const void *buf, size_t len) {
|
||||||
long n;
|
long n;
|
||||||
#if !defined(__APPLE__)
|
|
||||||
// See #1338, #1382. On Windows, UDP send() can fail despite connected.
|
|
||||||
// Use sendto() instead. But not on Mac - we'll get EISCONN
|
|
||||||
if (c->is_udp) {
|
if (c->is_udp) {
|
||||||
union usa usa;
|
union usa usa;
|
||||||
socklen_t slen = tousa(&c->peer, &usa);
|
socklen_t slen = tousa(&c->peer, &usa);
|
||||||
n = sendto(FD(c), (char *) buf, len, 0, &usa.sa, slen);
|
n = sendto(FD(c), (char *) buf, len, 0, &usa.sa, slen);
|
||||||
} else
|
} else {
|
||||||
#endif
|
|
||||||
{
|
|
||||||
n = send(FD(c), (char *) buf, len, MSG_NONBLOCKING);
|
n = send(FD(c), (char *) buf, len, MSG_NONBLOCKING);
|
||||||
}
|
}
|
||||||
return n == 0 ? -1 : n < 0 && mg_sock_would_block() ? 0 : n;
|
return n == 0 ? -1 : n < 0 && mg_sock_would_block() ? 0 : n;
|
||||||
|
|||||||
+1
-6
@@ -141,16 +141,11 @@ static void iolog(struct mg_connection *c, char *buf, long n, bool r) {
|
|||||||
|
|
||||||
static long mg_sock_send(struct mg_connection *c, const void *buf, size_t len) {
|
static long mg_sock_send(struct mg_connection *c, const void *buf, size_t len) {
|
||||||
long n;
|
long n;
|
||||||
#if !defined(__APPLE__)
|
|
||||||
// See #1338, #1382. On Windows, UDP send() can fail despite connected.
|
|
||||||
// Use sendto() instead. But not on Mac - we'll get EISCONN
|
|
||||||
if (c->is_udp) {
|
if (c->is_udp) {
|
||||||
union usa usa;
|
union usa usa;
|
||||||
socklen_t slen = tousa(&c->peer, &usa);
|
socklen_t slen = tousa(&c->peer, &usa);
|
||||||
n = sendto(FD(c), (char *) buf, len, 0, &usa.sa, slen);
|
n = sendto(FD(c), (char *) buf, len, 0, &usa.sa, slen);
|
||||||
} else
|
} else {
|
||||||
#endif
|
|
||||||
{
|
|
||||||
n = send(FD(c), (char *) buf, len, MSG_NONBLOCKING);
|
n = send(FD(c), (char *) buf, len, MSG_NONBLOCKING);
|
||||||
}
|
}
|
||||||
return n == 0 ? -1 : n < 0 && mg_sock_would_block() ? 0 : n;
|
return n == 0 ? -1 : n < 0 && mg_sock_would_block() ? 0 : n;
|
||||||
|
|||||||
Reference in new issue
Block a user