Đối với phiên bản kernel , giá trị thực tế sử dụng sẽ là một giá trị tối thiểu là 256 byte, giá trị tăng gấp đôi (trừ khi giá trị nhất định vượt quá tối đa hạt nhân). Một lần nữa, điều này nhấn mạnh thực tế rằng các thiết lập tùy chọn đều được gợi ý để hạt nhân, và không phải là tuyệt đối. Phạt cảnh cáo Lưu ý rằng thiết lập | Don t error on this BSD doesn t and if you think about it this is right. Otherwise apps have to play guess the biggest size games. RCVBUF SNDBUF are treated in BSD as hints if val sysctl_rmem_max val sysctl_rmem_max FIXME is this lower bound the right one sk- rcvbuf max val 2 256 break For kernel release the value actually used will be a minimum value of 256 bytes or the given value doubled unless the given value exceeds the kernel maximum . Again this emphasizes the fact that these option settings are hints to the kernel and are not absolute. Caution Note that setting the SOL_SOCKET options SO_SNDBUF or SO_RCVBUF only provides hints to the kernel from the application. The kernel will ultimately decide the final values that will be established. If it is critical for the application and kernel to precisely agree on these sizes the application should retrieve the final values established by the kernel. This is done with a subsequent call to the function getsockopt 2 . Retrieving the Socket Type so_type Some socket options can only be retrieved. The SO_TYPE is one such example. This option allows a subroutine which is passed a socket as a file descriptor to determine what kind of socket it is dealing with. Listing shows an example program that determines the type of the socket s. Listing Getting SO_TYPE Value of SOL_SOCKET Level Option 1 2 3 Get SO_TYPE Option 4 5 include 6 include Linux Socket Programming by Example - Warren W. Gay 308 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 include include include include sys include sys include This function reports the error and exits back to the shell static void bail const char on_what if errno 0 fputs strerror errno stderr fputs stderr fputs on_what stderr fputc n stderr exit 1 int main int argc char argv int z