We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi guys,
why or better when is the accept() returning zero filled IP and PORT? Sometimes I have there right IP and port and sometimes zero filled ip.
SOCKADDR_IN rem_addr = {0}; int addr_len = sizeof(SOCKADDR_IN); int retAccept = accept(rl_sock_id, (SOCKADDR *)&rem_addr, &addr_len );
Network Component Version 7.13.0RTOS2
There is no note about it in documentation https://www.keil.com/pack/doc/mw/Network/html/group__using__network__sockets__bsd__func.html#ga18e88467cfdbc3c361d53b9f928a87ab
Thank you!
You can follow this page to enable network debug output, which can help you to debug in more details:
www.keil.com/.../3982.htm
Matěj Jirka said:sometimes zero filled ip
does that correspond to an error return?
New socket id is returned. And it corresponds to sequence of IDs i get.
Thanks. It shows this:
05:36:03.684d NET: Before accept()<CR><LF> 05:36:03.685i RETARGET: 013.5 BSD:Accept Socket 1<LF><CR><LF> 05:36:03.685d NET: After accept()<CR><LF> 05:36:04.322i RETARGET: 014.1 BSD:Socket 2, Evt_Connect<LF><CR><LF> 05:36:04.324i RETARGET: 014.1 BSD: Address [10.12.12.2], port 55167<LF><CR><LF> 05:36:04.327i RETARGET: 014.1 BSD:Socket 2, Evt_Established<LF><CR><LF> 05:36:04.338i RETARGET: 014.1 BSD:Que_add 6 bytes, Socket 2<LF><CR><LF> 05:36:04.838i RETARGET: 014.6 BSD:Socket 2, Evt_Closed<LF><CR><LF> 05:36:05.184d NET: Before accept()<CR><LF> 05:36:05.185i RETARGET: 015.0 BSD:Accept Socket 1<LF><CR><LF> 05:36:05.185i RETARGET: 015.0 BSD: Child Socket 2 connected<LF><CR><LF> 05:36:05.186d NET: After accept()<CR><LF> 05:36:05.187d NET: CONREQ 0.0.0.0:0<CR><LF> 05:36:05.187i RETARGET: 015.0 BSD:Closesocket 2<LF><CR><LF>
So my opinion is that before I catch incoming socket by calling accept() and read incoming data. (Assume non-blocking mode) The socket is closed by opposite site. Am I right? Is it likely?NET: Is my Thread.Isn't it strange that incoming connection is accepted, received data and closed before I call accept() again?
The incoming connections in network BSD sockets are accepted or rejected by the protocol stack, not by the application. This concept has advantages and disadvantages. You can read more in the Winsock documentation here: docs.microsoft.com/.../so-conditional-accept If for some reason you call accept() too late, the socket may already be closed, so you can get the IP address unspecified (0.0.0.0)