今天试图把发送缓冲设为0,因为网上有人说这样的话阻塞返回就代表信息已经发送到另外一端了,试了一下,返回错误

代码
int  nZero=0;  
setsockopt(socket,SOL_S0CKET,SO_SNDBUF,(char  *)&nZero,sizeof(nZero));

help文件有如下描述
Specifies the total per-socket buffer space reserved for sends. This is unrelated to SO_MAX_MSG_SIZE or the size of a TCP window. Care should be taken when setting the SO_SNDBUF value as setting this value either too high or too low can have a negative effect on performance. It is also important to note that a value of 0 is not supported for SO_SNDBUF.


既然这样,不如看看发送缓冲的大小
     int   nZero = 0 ;  
    
int   iLen;
    iLen
= sizeof (nZero);
    err
= getsockopt(m_socket,SOL_SOCKET,SO_SNDBUF,( char * ) & nZero, & iLen); 
跟踪获得发送缓冲的大小是0x00004000,转成10进制是16384,就是16k吧