Developer

API Reference

ISockPort_RecvFrom()

Brew Release
Brew MP 1.0.2
See Also
None.
Description
This function reads data from a datagram socket and records the address of the sender.
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.
Parameters
  • po
    []:
    pointer to the ISockPort interface
  • pcBuf
    []:
    buffer to hold the received data
  • cbBuf
    []:
    size of the buffer, in bytes
  • dwFlags
    []:
    not used
  • pAddr
    []:
    a pointer to the address to be filled in (see AEESockAddrStorage)
  • pnSize
    []:
    a pointer to the size of the address. Prior to the call, this size should be initialized to the size of the space that pAddr points to. Upon return, this size will reflect the number of bytes written into pAddr.
Interface
Prototype
   int32 ISockPort_RecvFrom(ISockPort* po, char* pcBuf, int32 cbBuf,
                            uint32 dwFlags, void* pAddr, int* pnSize)
Return

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.
Side Effect
None.
Comment
Note that the IPORT_WAIT return value is used instead of an error return value and an AEE_NET_EWOULDBLOCK error code.
  • Follow