unexpected error on recv function via socket

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

unexpected error on recv function via socket

Gavin
Hi,

I meet one unexpected disconnect on recv function.

I have one test case and repeat it to test stability:
1. create one socket and connect to server.
2. data exchange with server.
3. close socket.

After several runs, it failed on recv function. I get the debug log like below:
--------------------------------------
test run : 155
lwip_socket(PF_INET, SOCK_STREAM, 0) = 0
lwip_connect(0, addr=10.0.2.23 port=10000)
lwip_connect(0) succeeded
lwip_send(0, data=2002a938, size=17, flags=0x0)
lwip_send(0) err=0 written=17
lwip_recvfrom(0, 2003b9f8, 9, 0x0, ..)
lwip_recvfrom: top while sock->lastdata=0
lwip_recvfrom: netconn_recv err=0, netbuf=2000f3cc
lwip_recvfrom: buflen=9 len=9 off=0 sock->lastoffset=0
lwip_recvfrom(0): addr=10.0.2.23 port=10000 len=9
lwip_recvfrom: deleting netbuf=2000f3cc
lwip_recvfrom(0, 2003b9f8, 40, 0x0, ..)
lwip_recvfrom: top while sock->lastdata=0
lwip_recvfrom: netconn_recv err=0, netbuf=2000ebac
lwip_recvfrom: buflen=40 len=40 off=0 sock->lastoffset=0
lwip_recvfrom(0): addr=10.0.2.23 port=10000 len=40
lwip_recvfrom: deleting netbuf=2000ebac
lwip_send(0, data=2002a908, size=40, flags=0x0)
lwip_send(0) err=0 written=40
lwip_send(0, data=2002a908, size=40, flags=0x0)
lwip_send(0) err=0 written=40
lwip_recvfrom(0, 2003b9f8, 40, 0x0, ..)
lwip_recvfrom: top while sock->lastdata=0
lwip_recvfrom: netconn_recv err=0, netbuf=2000e79c
lwip_recvfrom: buflen=40 len=40 off=0 sock->lastoffset=0
lwip_recvfrom(0): addr=10.0.2.23 port=10000 len=40
lwip_recvfrom: deleting netbuf=2000e79c
lwip_close(0)
test run : 156
lwip_socket(PF_INET, SOCK_STREAM, 0) = 0
lwip_connect(0, addr=10.0.2.23 port=10000)
lwip_connect(0) succeeded
lwip_send(0, data=2002a938, size=17, flags=0x0)
lwip_send(0) err=0 written=17
lwip_recvfrom(0, 2003b9f8, 9, 0x0, ..)
lwip_recvfrom: top while sock->lastdata=0
lwip_recvfrom: netconn_recv err=-13, netbuf=0              <-- error log
lwip_recvfrom(0): buf == NULL, error is "Not connected."! <-- socket still here
lwip_close(0)
--------------------------------------

The error number is -13 (ERR_CONN).
I have no idea about the reason, I check the socket is still exists , not clear at all.

Does anyone have some suggestion for me?

BTW, I work on TM4C platform with free rtos.

thanks
Gavin