Here is my code based on the Web server LWIp example :
I have files user.h, network_utilities.h, web_server.c (converted in eth_client.c) and my below file send.c :
#include <stdio.h># include <stdlib.h># include <string.h># include <ctype.h># include <sys/param.h># include <sys/fcntl.h># include "lwip/netif.h"# include "lwip/sockets.h"# include "arch/sys_arch.h"# include "sys/alt_alarm.h"# include "alt_types.h"# include "user.h"# include "io.h"
# ifdef DEBUG
# include alt_debug.h# else
# define ALT_DEBUG_ASSERT(a) # endif /* DEBUG */
# define nbc 100 // 225 // 200# define nbl 200 // 200 // 250# define fps 75
# define SEND_PORT 30 // TCP port number to listen on
int handle_send(int sock)
{
char* buffer;
int i, j;
int n, a, k;
buffer=(char *)calloc(nbl*nbc, sizeof(char));
for (i=0; i<nbl; i++) //Ecriture sur nbl lignes
{
for(j=0; j<nbc; j++) // une ligne contient nbc pixels
{
buffer = (char)(j+1);
}
}
printf(" Buffering data finished\n");
printf(" Buffer length : %d\n", strlen(buffer));
n = send(sock, buffer, strlen(buffer),0);
//int lwip_send(int s, void *dataptr, int size, unsigned int flags);
if (n < 0)
die_with_error(" error writing to socket\n");
return n;
}
void send_task()
{
int sock;
struct sockaddr_in addr;
printf(" Creating socket\n");
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
die_with_error(" Listening socket creation failed");
addr.sin_family = AF_INET;
addr.sin_port = htons(SEND_PORT);
addr.sin_addr.s_addr = inet_addr("10.0.0.11");
while ((connect(sock,(struct sockaddr *)&addr,sizeof(addr))) < 0)
printf(" Trying to connect to server\n");
printf(" Client sending on port %d\n", SEND_PORT);
if ((handle_send(sock)) <0)
printf(" Transmit failed\n");
printf(" End of Connection\n");
close(sock);
}
With that code, i can't send more than a buffer of 100x200 char. And i don't understand why! My pc server seems to correctly receive the data anyway.
So are there parameters to change in LWIP to send a certain amount of data like buffers or stacks?
Thanks for ur future answers.
Regards,
Xavier