1
0
Fork 0
forked from nuttx/nuttx-update

net/socket: Combine send() with sendto()

send() is just a specific flavor of sendto(), thus they can be combined.
This commit is contained in:
Ville Juven 2023-05-24 14:59:47 +03:00 committed by Xiang Xiao
parent ecaa62010a
commit 4ed4e3ca36

View file

@ -156,30 +156,7 @@ ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len,
ssize_t send(int sockfd, FAR const void *buf, size_t len, int flags)
{
FAR struct socket *psock;
ssize_t ret;
/* send is a cancellation point, but that can all be handled by sendto */
/* send() is a cancellation point */
enter_cancellation_point();
/* Get the underlying socket structure */
ret = sockfd_socket(sockfd, &psock);
/* And let psock_send do all of the work */
if (ret == OK)
{
ret = psock_send(psock, buf, len, flags);
}
if (ret < 0)
{
set_errno(-ret);
ret = ERROR;
}
leave_cancellation_point();
return ret;
return sendto(sockfd, buf, len, flags, NULL, 0);
}