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

Function at_closesocket

components/net/at/at_socket/at_socket.c:555–587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

553}
554
555int at_closesocket(int socket)
556{
557 struct at_socket *sock = RT_NULL;
558 enum at_socket_state last_state;
559
560 /* deal with TCP server actively disconnect */
561 rt_thread_delay(rt_tick_from_millisecond(100));
562
563 sock = at_get_socket(socket);
564 if (sock == RT_NULL)
565 {
566 rt_set_errno(ENXIO);
567 return -1;
568 }
569
570 last_state = sock->state;
571
572 /* the rt_at_socket_close is need some time, so change state in advance */
573 sock->state = AT_SOCKET_CLOSED;
574
575 if (last_state != AT_SOCKET_CLOSED)
576 {
577 if (sock->ops->at_closesocket(sock) != 0)
578 {
579 free_socket(sock);
580 rt_set_errno(EIO);
581 return -1;
582 }
583 }
584
585 free_socket(sock);
586 return 0;
587}
588
589int at_shutdown(int socket, int how)
590{

Callers 2

at_bindFunction · 0.85
at_connect_notice_cbFunction · 0.85

Calls 5

rt_thread_delayFunction · 0.85
rt_tick_from_millisecondFunction · 0.85
at_get_socketFunction · 0.85
rt_set_errnoFunction · 0.85
free_socketFunction · 0.70

Tested by

no test coverage detected