Commit af70e8f7 authored by Satya Bhattacharya's avatar Satya Bhattacharya Committed by Jukka Rissanen
Browse files

samples: net: Check the return value of close()



Check the return value of close() in socket_dumb_http.c
If non-zero, print the error code

Fixes #8413.

Signed-off-by: default avatarSatya Bhattacharya <satyacube@gmail.com>
parent 49554dd3
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ int main(void)
	int serv;
	struct sockaddr_in bind_addr;
	static int counter;
	int ret;

	serv = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
	CHECK(serv);
@@ -122,8 +123,13 @@ int main(void)
		}

close_client:
		close(client);
		ret = close(client);
		if (ret == 0) {
			printf("Connection from %s closed\n", addr_str);
		} else {
			printf("Got error %d while closing the "
			       "socket\n", errno);
		}

#if defined(__ZEPHYR__) && defined(CONFIG_NET_BUF_POOL_USAGE)
		struct k_mem_slab *rx, *tx;