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

Function lwip_shutdown

components/net/lwip/lwip-1.4.1/src/api/sockets.c:1379–1418  ·  view source on GitHub ↗

* Unimplemented: Close one end of a full-duplex connection. * Currently, the full connection is closed. */

Source from the content-addressed store, hash-verified

1377 * Currently, the full connection is closed.
1378 */
1379int
1380lwip_shutdown(int s, int how)
1381{
1382 struct lwip_sock *sock;
1383 err_t err;
1384 u8_t shut_rx = 0, shut_tx = 0;
1385
1386 LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_shutdown(%d, how=%d)\n", s, how));
1387
1388 sock = get_socket(s);
1389 if (!sock) {
1390 return -1;
1391 }
1392
1393 if (sock->conn != NULL) {
1394 if (netconn_type(sock->conn) != NETCONN_TCP) {
1395 sock_set_errno(sock, EOPNOTSUPP);
1396 return EOPNOTSUPP;
1397 }
1398 } else {
1399 sock_set_errno(sock, ENOTCONN);
1400 return ENOTCONN;
1401 }
1402
1403 if (how == SHUT_RD) {
1404 shut_rx = 1;
1405 } else if (how == SHUT_WR) {
1406 shut_tx = 1;
1407 } else if(how == SHUT_RDWR) {
1408 shut_rx = 1;
1409 shut_tx = 1;
1410 } else {
1411 sock_set_errno(sock, EINVAL);
1412 return EINVAL;
1413 }
1414 err = netconn_shutdown(sock->conn, shut_rx, shut_tx);
1415
1416 sock_set_errno(sock, err_to_errno(err));
1417 return (err == ERR_OK ? 0 : -1);
1418}
1419
1420static int
1421lwip_getaddrname(int s, struct sockaddr *name, socklen_t *namelen, u8_t local)

Callers

nothing calls this directly

Calls 4

get_socketFunction · 0.70
netconn_typeEnum · 0.70
netconn_shutdownFunction · 0.70
err_to_errnoFunction · 0.50

Tested by

no test coverage detected