在阻塞模式下send函数的返回值是不是永远都不会小于buffer的长度(即传入send的第3个参数)?MSDN里面的“If no buffer space is available within the transport system to hold the data to be transmitted, send will block unless the socket has been placed in nonblocking mode.”这句话没看懂,请前辈给解释解释。还有 using getsockopt() to retrieve the value of socket option SO_MAX_MSG_SIZE.——不是说SO_MAX_MSG_SIZE只对UDP有效吗?我做过试验在tcp socket里总是返回0——对吗?请前辈指点,谢谢!
则发送将一直被阻塞,直到Socket被设置为非阻塞模式。// 从这个意思看来,你可以在这个过程中设置Socket为非阻塞模式来解决这个问题
2、using getsockopt() to retrieve the value of socket option SO_MAX_MSG_SIZE.——不是说SO_MAX_MSG_SIZE只对UDP有效吗?//msdn上的原话:
The send function is used to write outgoing data on a connected socket. For message-oriented sockets, care must be taken not to exceed the maximum packet size of the underlying provider, which can be obtained by using getsockopt to retrieve the value of socket option SO_MAX_MSG_SIZE. If the data is too long to pass atomically through the underlying protocol, the error WSAEMSGSIZE is returned, and no data is transmitted.//这上面好像并没有说明只针对UDP吧!或许有,我没有看到!