Problem
I have written a program which uses setsockopt(SSC) to specify the size of the send queue buffer for an open socket using the option SO_SNDBUF. However, when this program queries this setting using setsockopt(SSC), the returned value for the send queue buffer is incorrect.
The following example demonstrates this behavior by calling setsockopt(SO_SNDBUF) with a 'unique' value of 7999; getsockopt(SO_SNDBUF), however, returns a value of 1 rather than 7999.
---------<Cut here>--------
/*
# cc -o sockopt sockopt.c -lsocket
# ./sockopt
PRE: send buffer size = 1
POST: send buffer size = 1 (should be 7999)
*/#include <sys/socket.h>#define SIZE 7999main()
{
int socketfd, sndbuf_sz, option_len;if ((socketfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) printf("error: socket() returned %d\n", socketfd);
option_len = sizeof(sndbuf_sz);if (getsockopt(socketfd, SOL_SOCKET, SO_SNDBUF, (char *) &sndbuf_sz, &option_len) < 0) printf("error: getsockopt(SO_SNDBUF) failed\n");
printf("PRE: send buffer size = %d\n", sndbuf_sz);
sndbuf_sz = SIZE;if (setsockopt(socketfd, SOL_SOCKET, SO_SNDBUF, (char *) &sndbuf_sz, sizeof(sndbuf_sz)) < 0) printf("error: setsockopt(SO_SNDBUF) failed\n");
option_len = sizeof(sndbuf_sz);if (getsockopt(socketfd, SOL_SOCKET, SO_SNDBUF, (char *) &sndbuf_sz, &option_len) < 0) printf("error: getsockopt(SO_SNDBUF) failed\n");
printf("POST: send buffer size = %d (should be %d)\n", sndbuf_sz, SIZE);
}
---------<Cut here>--------This source code behaves correctly when compiled and run on SCO Open Server 3.0, SCO UnixWare 2.x, and UnixWare 7.
Cause
Using the crash(ADM) utility, verify that setsockopt(SSC) has correctly set the send queue buffer size. For example:
# crash
> queue
QUEUE TABLE SIZE = 680
SLOT INFO NEXT LINK PTR RCNT HEAD TAIL MINP MAXP HIWT LOWT FLAGS
0 0xf01a0f18 - - 0xf08acf80 0 - - 0 -1 16384 1024 rr us
2 0xf01aacd0 4 - 0xf026ace8 0 - - 0 -1 4096 1 wr rr us
...
577 0xf01a82bc - - 0xf098f600 0 - - 0 7999 1 0 wr us
^^^^The "MAXP" field is the maximum packet size accepted by the streams queue.
getsockopt(SO_SNDBUF), however, incorrectly returns the high water mark value ("HIWT") for this queue instead of "MAXP".
Solution
Although getsockopt(SO_SNDBUF) returns the incorrect value when
executed on SCO OpenServer 5.0.0, 5.0.2 and 5.0.4, the setting
of this option by setsockopt(SO_SNDBUF) has been successfully
performed. Therefore, this incorrect behavior of getsockopt(SSC)
can be disregarded.This has been fixed in Release Supplement 504C (rs504c). Please
upgrade SCO OpenServer 5.0.0, 5.0.2 to SCO OpenServer 5.0.5 or
later. If you have SCO OpenServer 5.0.4, make sure you have
Release Supplement 504C. See also
ta105811 "What is the Release Supplement 504C for SCO OpenServer Release 5.0.4 (rs504c) and how can I obtain it?"