转自:http://blog.csdn.net/wf1982/article/details/38871521

参见 http://stackoverflow.com/questions/4257410/what-are-so-sndbuf-and-so-recvbuf

The "SO_" prefix is for "socket option", so yes, these are per-socket settings for the per-socket buffers. There are usually system-wide defaults and maximum values.

SO_RCVBUF is simpler to understand: it's the size of the buffer the kernel allocates to hold the data arriving into the given socket during the time between it arrives over the network and when it is read by the program that owns this socket. With TCP, if data arrives and you aren't reading it, the buffer will fill up, and the sender will be told to slow down (using TCP window adjustment mechanism). For UDP, once the buffer is full, new packets will just be discarded.

SO_SNDBUF, I think, only matters for TCP (in UDP, whatever you send goes directly out to the network). For TCP, you could fill the buffer either if the remote side isn't reading (so that remote buffer becomes full, then TCP communicates this fact to your kernel, and your kernel stops sending data, instead accumulating it in the local buffer until it fills up). Or it could fill up if there is a network problem, and the kernel isn't getting acknowledgements for the data it sends. It will then slow down sending data on the network until, eventually, the outgoing buffer fills up. If so, future write() calls to this socket by the application will block (or return EAGAIN if you've set the O_NONBLOCK option).

关于socket——SO_SNDBUF and SO_RECVBUF的更多相关文章

  1. python - socket - connection

    前面有了TCP server和TCP client.在这个文章中我们建立tcp连接并且进行数据的发送. 例子,经常用到的echo功能.TCP client连接到server, 向server发送mes ...

  2. Python3的tcp socket接收不定长数据包接收到的数据不全。

    Python Socket API参考出处:http://blog.csdn.net/xiangpingli/article/details/47706707 使用socket.recv(pack_l ...

  3. 百万年薪python之路 -- socket()模块的用法

    socket()模块的用法: import socket socket.socket(socket_family,socket_type,protocal=0) socket_family 可以是 A ...

  4. day8 socket

    代码: 例子1:socket tcp 通讯 server端 import socketserver = socket.socket()ip_port = ("127.0.0.1", ...

  5. python socket理解

    socket 所谓套接字(Socket),就是对网络中不同主机上的应用进程之间进行双向通信的端点的抽象.一个套接字就是网络上进程通信的一端,提供了应用层进程利用网络协议交换数据的机制.从所处的地位来讲 ...

  6. Python网络编程——修改套接字发送和接收的缓冲区大小

    很多情况下,默认的套接字缓冲区大小可能不够用.此时,可以将默认的套接字缓冲区大小改成一个更合适的值. 1. 代码 # ! /usr/bin/env python # -*- coding: utf-8 ...

  7. Netty Tutorial Part 1.5: On Channel Handlers and Channel Options [z]

    Intro: After some feedback on Part 1, and being prompted by some stackoverflow questions, I want to ...

  8. python网络编程应用(一)

     在之前的一篇博客<python网络编程基础>中介绍了socket.socket()函数及其应用,其实socket模块中还有很多属性可供网络应用程序使用.这里将详细讲解一下socket模块 ...

  9. python网络编程详解

    最近在看<UNIX网络编程 卷1>和<FREEBSD操作系统设计与实现>这两本书,我重点关注了TCP协议相关的内容,结合自己后台开发的经验,写下这篇文章,一方面是为了帮助有需要 ...

随机推荐

  1. CentOS用yum安装、配置MariaDB

    .创建/etc/yum.repos.d/MariaDB.repo文件,这里用到了刚刚发布正式版的10. [mariadb] name = MariaDB baseurl = http://yum.ma ...

  2. Oracle11g +Win 64+PLSQL9.0

    最近在Oracle11g配置数据库的时候发现了一个问题,就是找不到监听,网上说win7的64位的系统必须装上32位的客户端才能被PLSQL 识别,事实上也是这样,PLSQL 只能识别32位的客户端,所 ...

  3. hashCode与equals的区别与联系

    一.equals方法的作用 1.默认情况(没有覆盖equals方法)下equals方法都是调用Object类的equals方法,而Object的equals方法主要用于判断对象的内存地址引用是不是同一 ...

  4. js日期、月份:日期加一天等

    // 日期,在原有日期基础上,增加days天数,默认增加1天 function addDate(date, days) { if (days == undefined || days == '') { ...

  5. CentOS基础指令备忘

    功能 指令 可用参数 示例 说明 新建文件夹 mkdir   mkdir etc/temp 在当前目录的etc文件夹下新建temp文件夹 新建文件 vi   vi abc.sh 新建名为abc.sh的 ...

  6. Divide and conquer:Moo University - Financial Aid(POJ 2010)

    Moo University - Financial Aid 其实是老题了http://www.cnblogs.com/Philip-Tell-Truth/p/4926008.html 这一次我们换二 ...

  7. Mathematics:DNA Sorting(POJ 1007)

    DNA排序 题目大意:给定多个ACGT序列,按照字母顺序算出逆序数,按逆序数从小到大排列 这题其实很简单,我们只要用一个归并排序算逆序数,然后快排就可以了(插入排序也可以,数据量不大),但是要注意的是 ...

  8. 谷歌 Uncaught SecurityError: Failed to execute 'replaceState' on 'History 错误

    今天在用sui mobil做一个内联页面的时候遇到了这个问题. 然而这个问题只出现在chrome浏览器中,在火狐中没有一点问题. 他说明的是一个安全问题,chrome中有了新的安全机制

  9. HTML 样式表

    样式代码 样式代码与属性代码区别   样式代码必须带单位 属性不需要  多个样式代码之间用分号隔开  同一个样式里面 用空格  多个属性之间用空格隔开    举例 1.背景样式 .r { backgr ...

  10. linux 卸载软件

    sudo apt-get autoremove --purge 后跟要卸载的软件名称, --purge表示要完全卸载.