b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

setsockopt_setsockopt accept_setsockopt设置超时(5)

电脑杂谈  发布时间:2017-05-28 06:12:46  来源:网络整理

432

433 if (val > sysctl_rmem_max)

434 val = sysctl_rmem_max;

435 set_rcvbuf:

436 sk->sk_userlocks |= SOCK_RCVBUF_LOCK;

437 /*

438 * We double it on the way in to account for

439 * "struct sk_buff" etc. overhead. Applications

440 * assume that the SO_RCVBUF setting they make will

441 * allow that much actual data to be received on that

442 * socket.

443 *

444 * Applications are unaware that "struct sk_buff" and

445 * other overheads allocate from the receive buffer

446 * during socket buffer allocation.

447 *

448 * And after considering the possible alternatives,

449 * returning the value we actually used in getsockopt

450 * is the most desirable behavior.

451 */

452 if ((val * 2)

453 sk->sk_rcvbuf = SOCK_MIN_RCVBUF;

454 else

455 sk->sk_rcvbuf = val * 2;

456 break;

取得套接口类型

实际上我们只可以得到一些套接口选项。SO_TYPE就是其中的一例。这个选项会允许传递套接口的一个子函数来确定正在处理的是哪一种套接口类型。

如下面是一段得到套接口s类型的示例代码:

/*gettype.c

*

* Get SO_TYPE Option:

*/

#include

#include

#include

#include

#include

#include

#include

#include

/*

* This function report 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;

int s = -1; /* Socket */

int so_type = -1; /* Socket type */

socklen_t optlen; /* Option length */

/*

* Create a TCT/IP socket to use:

*/

s = socket(PF_INET,SOCK_STREAM,0);

if(s==-1)

bail("socket(2)");

/*

* Get socket option SO_TYPE:


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/ruanjian/article-49663-5.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...