socket相关知识
来源:互联网 发布:域名在哪注册好 编辑:程序博客网 时间:2024/05/17 08:48
1. Blocking/Non-blocking vs Sync/Async
- Blocking I/O means that thecalling system does not return control to the caller until the operation isfinished. As a result, the caller is blocked and cannot perform otheractivities during that time.
- Non-blocking Synchronous I/O means that call returnscontrol to the caller immediately and the caller is not made to wait. Theinvoked system immediately returns one of two responses: If the call wasexecuted and the results are ready, then the caller is told of that.Alternatively, the invoked system can tell the caller that the system has noresources (no data in the socket) to perform the requested action.
- Non-blocking Asynchronous I/O means that the callingfunction returns control to the caller immediately, reporting that therequested action was started. The invoked system will notify the caller (bycallback for example), when the result is ready for processing.
- Asynchronousrefers to something done in parallel,say is another thread.
- Non-blockingoften refers to polling, i.e.checking whether given condition holds
http://stackoverflow.com/questions/2625493/asynchronous-vs-non-blocking
http://www.ibm.com/developerworks/linux/library/l-async/
2. SO_RCVBUF&& SO_SNDBUF
If you use the SO_RCVBUF and SO_SNDBUF optionto set zero TCP stack receive and send buffer, you basically instructthe TCP stack to directly perform I/O using the buffer provided in yourI/O call. Therefore, in addition to the non-blocking advantage of theoverlapped socket I/O, the other advantage is better performance because yousave a buffer copy between the TCP stack buffer andthe user buffer for each I/O call.
When SO_SNDBUFis set to 0, which hasnice effect of causing send() and sendto() to not return until thepacket has been sent. This operation became blocked, because system used your(app) buffer instead of copy your buffer into winsock buffer ( which set to 0 )and return from the send()/sendto() immediately ( in the case of non-blockedsocket ). The ACK here will play the role when you have data more than MTU (1460 for ethernet ) , so data have to be divided and each next packet will besend only after ACK of previous , so in this case that not only blocked up todata copied into winsock buff but up to all the data will send.
http://xcybercloud.blogspot.com/2009/06/network-io-blockingnon-blocking-vs.html
3. SetSO_SNDBUF on Linux.
Sets or gets the maximum socket send bufferin bytes. The kernel doubles this value (to allow space for bookkeepingoverhead) when it is set using setsockopt(), and this doubled value is returned by getsockopt(). The default value is set by the wmem_defaultsysctl and the maximum allowed value is set by the wmem_max sysctl. The minimum (doubled) value for this optionis 2048.
http://stackoverflow.com/questions/2031109/understanding-set-getsockopt-so-sndbuf
- JAVA Socket 相关知识
- Socket相关知识
- socket相关知识
- socket相关知识
- Socket相关知识
- socket相关知识总结
- Socket-Java-客户端相关知识
- java的socket相关知识
- iOS socket 使用 相关知识
- linux socket编程相关知识的总结
- C#多线程和socket的相关知识
- Android基于客户端和服务器的Socket编程例子之Socket基础通讯--socket相关知识
- 网络编程中tcp,socket,http 的相关知识
- tinyhttpd学习笔记(二)socket相关知识
- http socket 等通信协议相关基知识理解
- Socket知识
- socket知识
- socket知识
- Twitter Storm: storm的一些常见模式
- Json
- modelsim10.1c写.v文件的时候没有高亮显示
- VP6804高清视频处理模块
- Twitter Storm源代码分析之TimeCacheMap
- socket相关知识
- Android防注入研究
- Twitter Storm源代码分析之acker工作流程
- Twitter Storm源代码分析之ZooKeeper中的目录结构
- Oracle备份监听日志
- 键盘键值对应表
- dos 小知识
- Request.QueryString[""],Request.QueryString.Get()以及Request.Form[""],Request.Form.Get区别
- android 电池状态侦听显示 电量 充电动态显示