Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Hi,

When a socket is readable, has the underlying network component of the device already read the data from the network and kept with it, Or does the read from the network happens only when application calls ISOCKET_Read.

- Herojit

ISOCKET_Read() reads data from a socket into a single buffer but as reading data from network not necessarily complete in one call as of being dependent on network speed and data size hence asynchronous call. At any point of time if data is not available so ISOCKET_Read() returns AEE_NET_WOULDBLOCK in callback. In this case you need to call ISOCKET_Readable().
Hope this helps.

ISOCKET_Read() reads data from a socket into a single buffer but as reading data from network not necessarily complete in one call as of being dependent on network speed and data size hence asynchronous call. At any point of time if data is not available so ISOCKET_Read() returns AEE_NET_WOULDBLOCK in callback. In this case you need to call ISOCKET_Readable().
Hope this helps.

Hi,
 
That means the actual 'read' from the network happens only when application calls ISOCKET_Read, rite?
 
The reason for this query is, we are working on a gaming application that relies heavily on  data recevied from the socket and graphics operation on the GUI. So there is overhead of network operation while doing Graphics operation and vice versa. So, during a asynchronous socket read operation if the network component of the device has already read so that when application calls ISOCKET_Read, there is only a buffer transfer from underlying layer to application, then we can ignore the overhead of the network operation. Please clarify.
 
- Herojit

Hi,
 
That means the actual 'read' from the network happens only when application calls ISOCKET_Read, rite?
 
The reason for this query is, we are working on a gaming application that relies heavily on  data recevied from the socket and graphics operation on the GUI. So there is overhead of network operation while doing Graphics operation and vice versa. So, during a asynchronous socket read operation if the network component of the device has already read so that when application calls ISOCKET_Read, there is only a buffer transfer from underlying layer to application, then we can ignore the overhead of the network operation. Please clarify.
 
- Herojit

Correct, First call is initiated by ISOCKET_Read() and then ISOCKET_Readable() on getting AEE_NET_WOULDBLOCK.
 ret = ISOCKET_Read(pMe->iSocket, (byte*)&buf, sizeof(uint32));
if (ret == AEE_NET_WOULDBLOCK)
{
      ISOCKET_Readable(pMe->iSocket, ReadCB, (void*)pMe);
}
once the operation is complete, you can can cancel it by calling ISOCKET_Cancel().

Correct, First call is initiated by ISOCKET_Read() and then ISOCKET_Readable() on getting AEE_NET_WOULDBLOCK.
 ret = ISOCKET_Read(pMe->iSocket, (byte*)&buf, sizeof(uint32));
if (ret == AEE_NET_WOULDBLOCK)
{
      ISOCKET_Readable(pMe->iSocket, ReadCB, (void*)pMe);
}
once the operation is complete, you can can cancel it by calling ISOCKET_Cancel().