1
0
mirror of https://github.com/janet-lang/janet synced 2025-01-13 09:00:26 +00:00

Use SOCK_CLOEXEC correctly.

This commit is contained in:
Calvin Rose 2020-05-07 07:55:08 -05:00
parent 79c3139748
commit 084fc9776d

View File

@ -494,7 +494,7 @@ static Janet cfun_net_connect(int32_t argc, Janet *argv) {
struct addrinfo *ai = janet_get_addrinfo(argv, 0);
/* Create socket */
JSock sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol | JSOCKFLAGS);
JSock sock = socket(ai->ai_family, ai->ai_socktype | JSOCKFLAGS, ai->ai_protocol);
if (!JSOCKVALID(sock)) {
freeaddrinfo(ai);
janet_panic("could not create socket");
@ -525,7 +525,7 @@ static Janet cfun_net_server(int32_t argc, Janet *argv) {
JSock sfd = JSOCKDEFAULT;
struct addrinfo *rp = NULL;
for (rp = ai; rp != NULL; rp = rp->ai_next) {
sfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol | JSOCKFLAGS);
sfd = socket(rp->ai_family, rp->ai_socktype | JSOCKFLAGS, rp->ai_protocol);
if (!JSOCKVALID(sfd)) continue;
/* Set various socket options */
int enable = 1;