转自: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. 【架构】How To Use HAProxy to Set Up MySQL Load Balancing

    How To Use HAProxy to Set Up MySQL Load Balancing Dec  2, 2013 MySQL, Scaling, Server Optimization U ...

  2. Redis提供的持久化机制(RDB和AOF)

    Redis提供的持久化机制 Redis是一种面向"key-value"类型数据的分布式NoSQL数据库系统,具有高性能.持久存储.适应高并发应用场景等优势.它虽然起步较晚,但发展却 ...

  3. Pywinauto在Windows Twain Driver自动化测试中的应用研究

    摘  要: 以Python为基础,结合对Twain Driver测试工具的具体需求,将Pywinauto引入到Twain Driver的自动化测试中.介绍了Pywinauto的基本概念,通过测试用例说 ...

  4. <转>VPN技术原理

    原文地址:VPN技术原理 VPN,Virtual Private Network(虚拟专用 网络),被定义为通过一个公用网络(通常是因特网)建立一个临时的.安全的连接,是一条穿过公用网络的安全.稳定的 ...

  5. effective OC2.0 52阅读笔记(四 协议与分类)

    23 通过委托与数据源协议进行对象间通信 总结:委托模式的常规委托模式中,信息从类Class流向受委托者delegate.数据源模式,信息从数据源datasource流向class.数据源和受委托者可 ...

  6. [C#]Datatable和json互相转换操作

    #region DataTable 转换为Json字符串实例方法 /// <summary> /// GetClassTypeJosn 的摘要说明 /// </summary> ...

  7. 【Excel 4.0 函数】REGISTER

    REGISTER.ID 返回指定的 DLL 或 代码资源注册过的函数 ID.如果 DLL 或 代码资源没有注册,这个函数将会注册它们,并返回 注册ID. REGISTER.ID 可以用于工作表(不同于 ...

  8. ios 中直接修改frame里边某个属性的简便方法

    参考:http://www.cnblogs.com/wengzilin/p/4359865.html 在iOS中view的frame属性使用地太频繁了,尤其是调UI的时候.我们知道,正常情况下我们无法 ...

  9. Linux 添加新硬盘 LVM操作(作用:新增硬盘的卷管理)

    1 查看当前系统硬盘及分区情况 (注:linux中SCSI的第1个硬盘/dev/sda,第2个硬盘/dev/sdb依此类推) 2 初始化分区sdb为物理卷pv pvcreate /dev/sdb  / ...

  10. IOS-CoreAnimation

    核心动画 •Core Animation是一组非常强大的动画处理API,使用它能做出非常炫丽的动画效果,而且往往是事半功倍! •使用它需要先添加QuartzCore.framework和引入对应的框架 ...