mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 01:05:54 +08:00
bs/libc/net: implement socketpair (3)
N/A Reference here: https://www.freebsd.org/cgi/man.cgi?apropos=0&sektion=2&query=socketpair&manpath=FreeBSD+7.0-current&format=html Change-Id: I2d09f5148b2a720d1e7f380503deb8910c951599 Signed-off-by: danguanghua <danguanghua@xiaomi.com>
This commit is contained in:
@@ -39,10 +39,9 @@ CSRCS += lib_addrconfig.c lib_base64.c lib_htons.c lib_htonl.c
|
||||
CSRCS += lib_inetaddr.c lib_inetaton.c lib_inetntoa.c
|
||||
CSRCS += lib_inetntop.c lib_inetpton.c
|
||||
CSRCS += lib_etherntoa.c lib_etheraton.c
|
||||
CSRCS += lib_socketpair.c
|
||||
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
CSRCS += lib_recvmsg.c lib_sendmsg.c lib_shutdown.c
|
||||
CSRCS += lib_recvmsg.c lib_sendmsg.c lib_shutdown.c lib_socketpair.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NET_LOOPBACK),y)
|
||||
|
||||
@@ -72,7 +72,7 @@ static int create_socket(int domain, int type, int protocol,
|
||||
int socketfd;
|
||||
|
||||
socketfd = socket(domain, type, protocol);
|
||||
if (socketfd < -1)
|
||||
if (socketfd < 0)
|
||||
{
|
||||
return socketfd;
|
||||
}
|
||||
@@ -162,12 +162,11 @@ int socketpair(int domain, int type, int protocol, int sv[2])
|
||||
}
|
||||
|
||||
sv[0] = accept(listener, &addr[0].addr, &len);
|
||||
close(listener);
|
||||
if (sv[0] < 0)
|
||||
{
|
||||
goto err;
|
||||
}
|
||||
|
||||
close(listener);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user