This commit is patch to add timeout on accept socket
- to prevent holding socket on libcoap-server, added timeout on socket
Change-Id: Ibd40f9ba9c69f272f10af91bed900a0b8faa40b8
Signed-off-by: Jin-Seong Kim <jseong82.kim@samsung.com>
struct sockaddr caddr;
socklen_t caddrlen;
+ struct timeval timeout = {10, 0}; /* Timeout for TCP accept */
+
#ifdef WITH_MBEDTLS
tls_session *session = NULL;
#endif
break;
}
+ if (setsockopt(ctx->sockfd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(struct timeval)) < 0) {
+ printf("coap_net_bind : failed to set socket option, errno %d\n", errno);
+ }
+
newsock = accept(ctx->sockfd, &caddr, &caddrlen);
if (newsock < 0) {