Skip to content
Snippets Groups Projects
recvfrom.c 29.2 KiB
Newer Older
  /* Set the socket state to receiving */
  psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_RECV);
  /* Perform the TCP/IP or UDP recv() operation */
#if defined(CONFIG_NET_UDP) && defined(CONFIG_NET_TCP)
  if (psock->s_type == SOCK_STREAM)
      ret = tcp_recvfrom(psock, buf, len, infrom);
      ret = udp_recvfrom(psock, buf, len, infrom);
#elif defined(CONFIG_NET_TCP)
  ret = tcp_recvfrom(psock, buf, len, infrom);
#elif defined(CONFIG_NET_UDP)
  ret = udp_recvfrom(psock, buf, len, infrom);
#else
  ret = -ENOSYS;
  /* Set the socket state to idle */

  psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_IDLE);

  /* Handle returned errors */
      err = -ret;
      goto errout;
  /* Success return */

errout:
  *get_errno_ptr() = err;
  return ERROR;
}

#endif /* CONFIG_NET */