BSD tcp socket - send error with large data size

Hi,
I use Thread X with RA6M3.
FSP version 5.1


I want to send via tcp 119k byte using BSD wrapper, but:

If i try to send with a single call to send() function i get an error errno = 107 and the tcp socket disconnect.

bytes_to_send = 118784;

status = send(accepted_socket, ((const char*)p_SCmos), bytes_to_send, 0);

I thought it was a problem with the number of packet pool and their size but even setting the size to 1568 with 32 packets even trying to send only 15k bytes at a time I get an error.

The only wait to make it to go is to split with small send():

#define MAX_ONE_TIME_SEND_BYTES 1000

remaining_bytes = 118784

while(remaining_bytes > 0){

if(remaining_bytes > MAX_ONE_TIME_SEND_BYTES){

bytes_to_send = MAX_ONE_TIME_SEND_BYTES;

} else {

bytes_to_send = remaining_bytes;

}

status = send(accepted_socket, ((const char*)p_SCmos + (118784 - remaining_bytes)), bytes_to_send, 0);

if(status == -1){

SetLed(RED);

D(printf("Error sending body GetRawImage!\n"));

 }


What is the connection with  the BSD send() and packet pools? 
I thought that BSD send() took care of dividing my data to send it and not having to do it myself.
The only limit i think may be space due to the number of packets * packet size, but even if i use 1568 * 32 = 50176 a send with only 15k at a time it should work but it doesn't.
Can you explain to me why?

Parents Reply Children