ERROR on accept: Invalid argument
Hello,i get an error while running the minimal-http-server-mimetypes on my mobile,but just sometimes,and i almost tried my best to reshow the error but it works well until now.I searched the error message on the internet but,i'm not sure which one would be the reason or something else caused the error:
- invalid fd while call accept
2.uninitialized variable addrlen while call accept.
Thanks.
hmmmm what does it mean 'invalid fd'... who says it? Errno at runtime? It's -1 or garbage?
"uninitialized".... who says it... compiler? What file and line? Or you mean it contains garbage at runtime?
What version of lws? What is the platform, android?
Problem with accept()... you're not using tls?
I'm sorry that i didn't describe my question clearly just now.
The error write below:
ERROR on accept: Invalid argument
Then,i searched the text "ERROR on accept" in the project,it showed that only two files contains the text,they are
`c++
libwebsockets/lib/roles/listen/ops-listen.c
libwebsockets/test-apps/fuzxy.c
the code looks like: //libwebsockets/lib/roles/listen/ops-listen.c:67 clilen = sizeof(cli_addr); lws_latency_pre(context, wsi);
/*
* We cannot identify the peer who is in the listen
* socket connect queue before we accept it; even if
* we could, not accepting it due to PEER_LIMITS would
* block the connect queue for other legit peers.
*/
accept_fd = accept((int)pollfd->fd,
(struct sockaddr *)&cli_addr, &clilen);
lws_latency(context, wsi, "listener accept",
(int)accept_fd, accept_fd != LWS_SOCK_INVALID);
if (accept_fd == LWS_SOCK_INVALID) {
if (LWS_ERRNO == LWS_EAGAIN ||
LWS_ERRNO == LWS_EWOULDBLOCK) {
break;
}
lwsl_err("ERROR on accept: %s\n",
strerror(LWS_ERRNO));
break;
}
`
Next,i searched the keywords "accept" on the internet and got the two possible reasons.
The platform i'm using is not android or ios,it's another platform using arm64 cpu-structure.The LWS's version is 3.0.0.
I will check whether i use the TLS following.
Exactly how accept() acts depends on your platform / os / tcp/ip stack. But at least for linux
EINVAL Socket is not listening for connections, or addrlen is invalid
(e.g., is negative).
Lws doesn't do this on linux. From the way the code is, clilen is always initialized. And the listening socket is always in listening state until the vhost is destroyed.
I guess it's not any lws problem... I'd look into the source for the platform accept() api and find out the conditions it can return EINVAL errno. Maybe set errno = 0 before the call to accept() in lws in case the accept() is buggy and returns -1 without setting errno.
... and 3.0 is not getting updates. You should use at least v3.1.
Hmmm,thanks for reply.I will go on with the error.
If you get more info please add it here, but for now closing this since there's nothing for me to do about it.