Difference Between AEE_NET_WOULDBLOCK and 0 | developer.brewmp.com Difference Between AEE_NET_WOULDBLOCK and 0 | developer.brewmp.com

Developer

Difference Between AEE_NET_WOULDBLOCK and 0

Forums:

I"m confused about the return value of ISOCKET_Read(). What is the difference between AEE_NET_WOULDBLOCK and 0? It seems that if there were no bytes in the pipe and you are still connected, you should receive AEE_NET_WOULDBLOCK. If you were disconnected you should receive an error. What is the purpose of 0 return value?

tylerc wrote:I"m confused about the return value of ISOCKET_Read(). What is the difference between AEE_NET_WOULDBLOCK and 0? It seems that if there were no bytes in the pipe and you are still connected, you should receive AEE_NET_WOULDBLOCK. If you were disconnected you should receive an error. What is the purpose of 0 return value?
IME if you receive 0 your server has gracefully disconnected.
AEE_NET_WOULDBLOCK means you are still connected and could
receive data (if the server were to send any).

tylerc wrote:I"m confused about the return value of ISOCKET_Read(). What is the difference between AEE_NET_WOULDBLOCK and 0? It seems that if there were no bytes in the pipe and you are still connected, you should receive AEE_NET_WOULDBLOCK. If you were disconnected you should receive an error. What is the purpose of 0 return value?
IME if you receive 0 your server has gracefully disconnected.
AEE_NET_WOULDBLOCK means you are still connected and could
receive data (if the server were to send any).

return AEE_NET_WOULDBLOCK means there were some bytes in the pipe,you need do read again,
if (nRead == AEE_NET_WOULDBLOCK)
{
ISOCKET_Readable(m_pISocket,(PFNNOTIFY)ReadDataCB,this);
return;

return 0 means there were no bytes in the pipe and you are still connected,you didnot need to read. ;)

return AEE_NET_WOULDBLOCK means there were some bytes in the pipe,you need do read again,
if (nRead == AEE_NET_WOULDBLOCK)
{
ISOCKET_Readable(m_pISocket,(PFNNOTIFY)ReadDataCB,this);
return;

return 0 means there were no bytes in the pipe and you are still connected,you didnot need to read. ;)

lvqiang wrote:return AEE_NET_WOULDBLOCK means there were some bytes in the pipe,you need do read again,
if (nRead == AEE_NET_WOULDBLOCK)
{
ISOCKET_Readable(m_pISocket,(PFNNOTIFY)ReadDataCB,this);
return;

return 0 means there were no bytes in the pipe and you are still connected,you didnot need to read. ;)
That's not quite correct.
AEE_NET_WOULDBLOCK means that there are no bytes in the socket's buffer. If there were any you would be told - say you were trying to read 10 bytes and there were 5 in the buffer, then the return value would be 5. However, it also means that the socket is still open, and you should call ISOCKET_Readable, which will then notify you about a change in the state of the socket.
A return code of 0 means the socket has been closed. And you did need to read, or you wouldn't have found out that the socket had been closed!

lvqiang wrote:return AEE_NET_WOULDBLOCK means there were some bytes in the pipe,you need do read again,
if (nRead == AEE_NET_WOULDBLOCK)
{
ISOCKET_Readable(m_pISocket,(PFNNOTIFY)ReadDataCB,this);
return;

return 0 means there were no bytes in the pipe and you are still connected,you didnot need to read. ;)
That's not quite correct.
AEE_NET_WOULDBLOCK means that there are no bytes in the socket's buffer. If there were any you would be told - say you were trying to read 10 bytes and there were 5 in the buffer, then the return value would be 5. However, it also means that the socket is still open, and you should call ISOCKET_Readable, which will then notify you about a change in the state of the socket.
A return code of 0 means the socket has been closed. And you did need to read, or you wouldn't have found out that the socket had been closed!