Show quoted text>
> First, this test expects that double buffer length size which is set
> setsockopt is got from getsockopt, this behavior is only Linux.
> Other UNIX system, such as FreeBSD, same buffer size is got from
> getsockopt. So you should not expect double value which is set
> setsockopt.
use Socket;
use POSIX::Socket;
my $buflen = "8192";
my $sock = _socket(AF_INET, SOCK_DGRAM, 0) or die "socket: $!\n";
my $rv1 = _setsockopt($sock, SOL_SOCKET, SO_RCVBUF, pack("L", $buflen));
my $rv2 = _getsockopt($sock, SOL_SOCKET, SO_RCVBUF, my $ret, 4);
_close($sock);
printf "Got %d\n", unpack("L", $ret);
This test outputs are
Linux: Got 16384
FreeBSD: Got 8192
Show quoted text>
> Second buffer size 1000 is too small. In Linux if buffer size which is
> argument of setsockopt is smaller than under limit, double of under
> limit size is got from getsockopt. Under limit size of general Linux
> system is larger than 1000, so getsockopt does not return 2000.
> You should use larger than under limit size.
use Socket;
use POSIX::Socket;
my $buflen = "1000";
my $sock = _socket(AF_INET, SOCK_DGRAM, 0) or die "socket: $!\n";
my $rv1 = _setsockopt($sock, SOL_SOCKET, SO_RCVBUF, pack("L", $buflen));
my $rv2 = _getsockopt($sock, SOL_SOCKET, SO_RCVBUF, my $ret, 4);
_close($sock);
printf "Got %d\n", unpack("L", $ret);
This test outputs are
Linux: Got 2240
FreeBSD: Got 1000
Under limit of buffer size depends on environment.