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

Function sal_closesocket

components/net/sal/src/sal_socket.c:1150–1185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1148}
1149
1150int sal_closesocket(int socket)
1151{
1152 struct sal_socket *sock;
1153 struct sal_proto_family *pf;
1154 int error = 0;
1155
1156 /* get the socket object by socket descriptor */
1157 SAL_SOCKET_OBJ_GET(sock, socket);
1158
1159 /* clsoesocket operation not need to vaild network interface status */
1160 /* valid the network interface socket opreation */
1161 SAL_NETDEV_SOCKETOPS_VALID(sock->netdev, pf, closesocket);
1162
1163 if (pf->skt_ops->closesocket((int)(size_t)sock->user_data) == 0)
1164 {
1165#ifdef SAL_USING_TLS
1166 if (SAL_SOCKOPS_PROTO_TLS_VALID(sock, closesocket))
1167 {
1168 if (proto_tls->ops->closesocket(sock->user_data_tls) < 0)
1169 {
1170 return -1;
1171 }
1172 }
1173#endif
1174 error = 0;
1175 }
1176 else
1177 {
1178 error = -1;
1179 }
1180
1181 /* delete socket */
1182 socket_delete(socket);
1183
1184 return error;
1185}
1186
1187#define ARPHRD_ETHER 1 /* Ethernet 10/100Mbps. */
1188#define ARPHRD_LOOPBACK 772 /* Loopback device. */

Callers 6

dfs_net_closeFunction · 0.85
acceptFunction · 0.85
closesocketFunction · 0.85
check_network_statusFunction · 0.85
close_test_socketFunction · 0.85
TC_sal_socket_closeFunction · 0.85

Calls 1

socket_deleteFunction · 0.85

Tested by

no test coverage detected