End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
Socket::Option.linger
Socket::Option.linger(onoff, secs) => sockopt
ext/socket/option.c
View on GitHub ↗
static VALUE
sockopt_s_linger(VALUE klass, VALUE vonoff, VALUE vsecs)
{
VALUE tmp;
struct linger l;
memset(&l, 0, sizeof(l));
if (!NIL_P(tmp = rb_check_to_integer(vonoff, "to_int")))
l.l_onoff = NUM2INT(tmp);
else
l.l_onoff = RTEST(vonoff) ? 1 : 0;
l.l_linger = NUM2INT(vsecs);
return rsock_sockopt_new(AF_UNSPEC, SOL_SOCKET, SO_LINGER, pack_var(l));
}
Creates a new Socket::Option object for SOL_SOCKET/SO_LINGER.
onoff should be an integer or a boolean.
secs should be the number of seconds.
Example
p Socket::Option.linger(true, 10) #=> #<Socket::Option: UNSPEC SOCKET LINGER on 10sec>
See also
#linger
.ipv4_multicast_ttl
.new
.ipv4_multicast_loop
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0