This function always returns immediately with the number of bytes read. If no packets have arrived and the socket is still in a valid state, ISockPort_RecvFrom() will return IPORT_WAIT. ISockPort_Readable() may be used to receive notification of when to try ISockPort_RecvFrom() again.
Prior to performing any socket-specific behavior, ISockPort_RecvFrom() will try to acquire an IP address and ensure the underlying network layer is ready for communication. This may involve the establishment of an Internet connection using CDMA Packet Data or QNC if such a connection has not already been established. Finally, any previously-requested ISockPort_Bind() operation will be attempted if necessary. As a result, errors relating to network startup or ISockPort_Bind() could be reported here, and IPORT_WAIT return values are commonly encountered.
int32 ISockPort_RecvFrom(ISockPort* po, char* pcBuf, int32 cbBuf, uint32 dwFlags, void* pAddr, int* pnSize)
bytes_read (>=0) : any non-negative number indicates a number of bytes that have been successfully read into the provided buffer
IPORT_WAIT : No data available now; try again later. (See ISockPort_Readable())
IPORT_ERROR : the specific error code can be retrieved by calling ISockPort_GetLastError():
- AEE_NET_EBADF : socket is not open
- AEE_NET_EMFILE : not enough resources to complete
- this operation (too many sockets are in use).
- AEE_NET_ENETDOWN : network is not available (e.g. handset is outside
- of coverage area)
- AEE_NET_EOPNOTSUPP: not a datagram socket
- AEE_NET_EADDRINUSE: attempted to bind to local port already in use
- AEE_NET_EFAULT : invalid pcBuf pointer
- AEE_NET_EINVAL : socket not bound
- The following error codes can be returned in case there is no data to read,
- the AEE_SO_ERROR_ENABLE socket option is enabled and there is a pending
- ICMP error for the socket:
- AEE_NET_ENETUNREACH : network is unreachable
- AEE_NET_EHOSTUNREACH: host is unreachable
- AEE_NET_EHOSTDOWN : host is down
- AEE_NET_ENONET : host is not on the network
- AEE_NET_EPROTO : protocol error
- AEE_NET_EACCES : access denied
- AEE_NET_ENOPROTOOPT : protocol unreachable
- AEE_NET_ECONNREFUSED: port unreachable
- AEE_NET_EMSGSIZE : message too large
- AEE_NET_EOPNOTSUPP : operation not supported
- Other error codes are also possible.