mirror of
https://github.com/apache/nuttx.git
synced 2026-09-28 15:54:57 +08:00
Networking: Start the network monitor for a socket when a TCP socket is dup'ed.
This commit is contained in:
+12
-1
@@ -38,7 +38,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#ifdef CONFIG_NET
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <errno.h>
|
||||
@@ -48,8 +47,11 @@
|
||||
#include <nuttx/net/net.h>
|
||||
#include <nuttx/net/udp.h>
|
||||
|
||||
#include "tcp/tcp.h"
|
||||
#include "socket/socket.h"
|
||||
|
||||
#ifdef CONFIG_NET
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -101,6 +103,15 @@ int net_clone(FAR struct socket *psock1, FAR struct socket *psock2)
|
||||
DEBUGASSERT(psock2->s_sockif != NULL && psock2->s_sockif->si_addref != NULL);
|
||||
psock2->s_sockif->si_addref(psock2);
|
||||
|
||||
#ifdef NET_TCP_HAVE_STACK
|
||||
/* For connected socket types, it is necessary to also start the network monitor so
|
||||
* that the newly cloned socket can receive a notification if the network connection
|
||||
* is lost.
|
||||
*/
|
||||
|
||||
ret = tcp_start_monitor(psock2);
|
||||
#endif
|
||||
|
||||
net_unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -354,5 +354,24 @@ int net_timeo(systime_t start_time, socktimeo_t timeo);
|
||||
ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len,
|
||||
int flags);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_clone
|
||||
*
|
||||
* Description:
|
||||
* Performs the low level, common portion of net_dupsd() and net_dupsd2()
|
||||
*
|
||||
* Input Parameters:
|
||||
* psock1 - The existing socket that is being cloned.
|
||||
* psock2 - A reference to an uninitialized socket structure alloated by
|
||||
* the caller.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||
* any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int net_clone(FAR struct socket *psock1, FAR struct socket *psock2);
|
||||
|
||||
#endif /* CONFIG_NET */
|
||||
#endif /* _NET_SOCKET_SOCKET_H */
|
||||
|
||||
Reference in New Issue
Block a user