diff options
Diffstat (limited to 'ext/socket')
-rw-r--r-- | ext/socket/ipsocket.c | 2 | ||||
-rw-r--r-- | ext/socket/lib/socket.rb | 4 | ||||
-rw-r--r-- | ext/socket/mkconstants.rb | 2 | ||||
-rw-r--r-- | ext/socket/unixsocket.c | 2 |
4 files changed, 5 insertions, 5 deletions
diff --git a/ext/socket/ipsocket.c b/ext/socket/ipsocket.c index 9d713d0afd..bc93140d68 100644 --- a/ext/socket/ipsocket.c +++ b/ext/socket/ipsocket.c @@ -105,7 +105,7 @@ init_inetsock_internal(struct inetsock_arg *arg) arg->fd = -1; if (type == INET_SERVER) { - status = listen(fd, 5); + status = listen(fd, SOMAXCONN); if (status < 0) { close(fd); rb_sys_fail("listen(2)"); diff --git a/ext/socket/lib/socket.rb b/ext/socket/lib/socket.rb index 34a4379336..d5201ef788 100644 --- a/ext/socket/lib/socket.rb +++ b/ext/socket/lib/socket.rb @@ -182,7 +182,7 @@ class Addrinfo end # creates a listening socket bound to self. - def listen(backlog=5) + def listen(backlog=Socket::SOMAXCONN) sock = Socket.new(self.pfamily, self.socktype, self.protocol) begin sock.ipv6only! if self.ipv6? @@ -386,7 +386,7 @@ class Socket < BasicSocket ai_list = Addrinfo.getaddrinfo(host, 0, nil, :STREAM, nil, Socket::AI_PASSIVE) sockets = ip_sockets_port0(ai_list, true) sockets.each {|s| - s.listen(5) + s.listen(Socket::SOMAXCONN) } sockets ensure diff --git a/ext/socket/mkconstants.rb b/ext/socket/mkconstants.rb index 124a094946..613850777d 100644 --- a/ext/socket/mkconstants.rb +++ b/ext/socket/mkconstants.rb @@ -688,7 +688,7 @@ INET6_ADDRSTRLEN 46 Maximum length of an IPv6 address string IFNAMSIZ nil Maximum interface name size IF_NAMESIZE nil Maximum interface name size -SOMAXCONN nil Maximum connection requests that may be queued for a socket +SOMAXCONN 5 Maximum connection requests that may be queued for a socket SCM_RIGHTS nil Access rights SCM_TIMESTAMP nil Timestamp (timeval) diff --git a/ext/socket/unixsocket.c b/ext/socket/unixsocket.c index f29724db25..f8017924a8 100644 --- a/ext/socket/unixsocket.c +++ b/ext/socket/unixsocket.c @@ -66,7 +66,7 @@ rsock_init_unixsock(VALUE sock, VALUE path, int server) } if (server) { - if (listen(fd, 5) < 0) { + if (listen(fd, SOMAXCONN) < 0) { close(fd); rb_sys_fail("listen(2)"); } |