MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / lwip_close

Function lwip_close

components/net/lwip/lwip-2.1.2/src/api/sockets.c:793–832  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

791}
792
793int
794lwip_close(int s)
795{
796 struct lwip_sock *sock;
797 int is_tcp = 0;
798 err_t err;
799
800 LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_close(%d)\n", s));
801
802 sock = get_socket(s);
803 if (!sock) {
804 return -1;
805 }
806
807 if (sock->conn != NULL) {
808 is_tcp = NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_TCP;
809 } else {
810 LWIP_ASSERT("sock->lastdata == NULL", sock->lastdata.pbuf == NULL);
811 }
812
813#if LWIP_IGMP
814 /* drop all possibly joined IGMP memberships */
815 lwip_socket_drop_registered_memberships(s);
816#endif /* LWIP_IGMP */
817#if LWIP_IPV6_MLD
818 /* drop all possibly joined MLD6 memberships */
819 lwip_socket_drop_registered_mld6_memberships(s);
820#endif /* LWIP_IPV6_MLD */
821
822 err = netconn_prepare_delete(sock->conn);
823 if (err != ERR_OK) {
824 sock_set_errno(sock, err_to_errno(err));
825 done_socket(sock);
826 return -1;
827 }
828
829 free_socket(sock, is_tcp);
830 set_errno(0);
831 return 0;
832}
833
834int
835lwip_connect(int s, const struct sockaddr *name, socklen_t namelen)

Callers 15

test_sockets.cFile · 0.50
test_sockets_msgapi_tcpFunction · 0.50
test_sockets_msgapi_udpFunction · 0.50
test_sockets_msgapi_cmsgFunction · 0.50
START_TESTFunction · 0.50
pingFunction · 0.50
lwip_netdev_pingFunction · 0.50

Calls 8

netconn_prepare_deleteFunction · 0.85
done_socketFunction · 0.85
get_socketFunction · 0.70
netconn_typeEnum · 0.70
err_to_errnoFunction · 0.70
free_socketFunction · 0.70

Tested by 11

test_sockets_msgapi_tcpFunction · 0.40
test_sockets_msgapi_udpFunction · 0.40
test_sockets_msgapi_cmsgFunction · 0.40
START_TESTFunction · 0.40
test_socket_optionsFunction · 0.40
tcpecho_socket_entryFunction · 0.40