StupidBeauty
Read times:497Posted at:Wed Nov 16 17:38:04 2011

转载:setsockopt()用法(参数详细说明)

setsockopt函数的第4个参数,也就是optval(选项值)的实参,在调用完setsockopt函数之后便可弃用。因此这个实参可使用一个局部变量来充当,如果是由新分配的内存来充当这个实参的话,那就要在调用完setsockopt之后释放对应的内存,否则就泄漏咯。

http://blog.csdn.net/chary8088/article/details/2486377

亮点:

示例代码如下:

intfd, on = 1;

/* 此处是创建套接字等操作,出于篇幅的考虑省略*/

setsockopt (fd, SOL_TCP, TCP_CORK, &on, sizeof (on)); /* cork */
write (fd, …);
fprintf (fd, …);
sendfile (fd, …);
write (fd, …);
sendfile (fd, …);

on = 0;
setsockopt (fd, SOL_TCP, TCP_CORK, &on, sizeof (on)); /* 拔去塞子 */

Your opinions
Your name:Email:Website url:Opinion content:
- no title specified

HxLauncher: Launch Android applications by voice commands

 
Recent comments
2017年4月~2019年4月垃圾短信排行榜Posted at:Thu Sep 26 04:51:48 2024
Qt5.7文档翻译:QWebEngineCookieStore类,QWebEngineCookieStore ClassPosted at:Fri Aug 11 06:50:35 2023盲盒kill -9 18289 Grebe.20230517.211749.552.mp4