mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 01:05:54 +08:00
Adds OS internal functions nx_send(), ns_recv(), and nx_recvfrom() which are functionally equivalent to send(), recv(), and recvfrom() except that they do not set the errno variable and do not cause cancellation points.
This commit is contained in:
+6
-1
@@ -48,6 +48,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/cancelpt.h>
|
||||
#include <nuttx/net/net.h>
|
||||
|
||||
#include "inode/inode.h"
|
||||
|
||||
@@ -145,7 +146,11 @@ ssize_t read(int fd, FAR void *buf, size_t nbytes)
|
||||
* the errno variable.
|
||||
*/
|
||||
|
||||
ret = recv(fd, buf, nbytes, 0);
|
||||
ret = nx_recv(fd, buf, nbytes, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
goto errout;
|
||||
}
|
||||
#else
|
||||
/* No networking... it is a bad descriptor in any event */
|
||||
|
||||
|
||||
+7
-4
@@ -52,6 +52,7 @@
|
||||
#endif
|
||||
|
||||
#include <nuttx/cancelpt.h>
|
||||
#include <nuttx/net/net.h>
|
||||
|
||||
#include "inode/inode.h"
|
||||
|
||||
@@ -167,11 +168,13 @@ ssize_t write(int fd, FAR const void *buf, size_t nbytes)
|
||||
#endif
|
||||
{
|
||||
#if defined(CONFIG_NET_TCP) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
/* Write to a socket descriptor is equivalent to send with flags == 0.
|
||||
* Note that send() will set the errno on failure.
|
||||
*/
|
||||
/* Write to a socket descriptor is equivalent to send with flags == 0. */
|
||||
|
||||
ret = send(fd, buf, nbytes, 0);
|
||||
ret = nx_send(fd, buf, nbytes, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
goto errout;
|
||||
}
|
||||
#else
|
||||
ret = -EBADF;
|
||||
goto errout;
|
||||
|
||||
Reference in New Issue
Block a user