[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] Socket: Connection closed before sending all data
From: |
ricardoschoof |
Subject: |
[lwip-users] Socket: Connection closed before sending all data |
Date: |
Mon, 20 May 2019 23:59:14 -0700 (MST) |
When making a basic http server (listen -> accept -> send basic html
repsonse), I get an error when receiving a lot of data (~100k).
Firefox "The connection was reset"
Edge just show the data partially
Telnet won't show all the data, and get a "Connection to host
lost."-message.
I expect the application (since BSD style sockets are blocking) to send the
data before returning, and thereafter close the connection.
When sending smaller amounts of data (~70 bytes) this won't happen. It looks
like the socket are closed before sending the last data / receiving the last
ack. I have attached the wireshark capture.
My set up: STM32H7, FreeRTOS 10.2.0, LWIP 2.1.2
Ricardo Schoof
Code:
static void http_handler( void* pvParams ){
const unsigned char* HTTP_RESPONSE="HTTP/1.0 200 OK\r\nContent-Type:
text/html\r\n\r\n<div id='lipsum'><p>Lorem[...]"; [extended to 101321 bytes
of data]
const size_t send_length = strlen ((const char*)HTTP_RESPONSE) + 1;
int list_sock = 0, client_sock = 0;
struct sockaddr_in sLocalAddr;
list_sock = socket(AF_INET, SOCK_STREAM, 0);
sLocalAddr.sin_family = AF_INET;
sLocalAddr.sin_len = sizeof(sLocalAddr);
sLocalAddr.sin_addr.s_addr = 0;
sLocalAddr.sin_port = ntohs((int) pvParams);
if (bind (list_sock, (struct sockaddr *)&sLocalAddr, sizeof(sLocalAddr)) <
0)
http_err();
if ( lwip_listen(list_sock, 5) != 0 ){
lwip_close(list_sock);
http_err();
}
for (;;)
{
struct sockaddr_in client_addr;
int addrlen=sizeof(client_addr);
client_sock = lwip_accept(list_sock, (struct sockaddr*)&client_addr,
(socklen_t*)&addrlen);
if (client_sock>0){
lwip_send(client_sock, HTTP_RESPONSE, send_length, 0);
lwip_close(client_sock);
}
}
--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html
- [lwip-users] Socket: Connection closed before sending all data,
ricardoschoof <=