FTP send buffer size problem

Hello to all,

I am trying to send some data to FTP over GPRS.

My code working fine till data buffer size 5840bytes.

But i need to write more data upto 20,000bytes. So that i can set the send buffer size WIP_COPT_SND_BUFSIZE = 20000 through setOpts function. but this function return error as “WIP_CERR_NOT_SUPPORTED”.

What is cause by this error arrives? What is the solution?

Please some one help me to slove this problem.

Thanks & regards,

Once you’ve pushed 5.8KB to send, TCP buffers are full, you can’t stack more until these first 5.8KB are sent and acknowledged by the server, as requested by the TCP protocol. You’ll receive a WIP_CEV_WRITE message on the file’s event handler when some emission buffer space will have been freed. If you want, you can customize the minimal amount of buffer to get freed before you receive WIP_CEV_WRITE, by tuning WIP_COPT_SND_LOWAT with wip_setOpts(), refer to the doc for details.

Hi fft,

Thanks for the reply.

your logic is Ok.

Now, simply i want to know what is the “WIP_COPT_SND_BUFSIZE” maximum size?
This parameter prototype is u32 ( as on documentation). I am trying to set “WIP_COPT_SND_BUFSIZE” as 20,000 bytes for an my application requirement. Is this possible or not?

Thanks

You are missing the point.

Your application requirement is to send a total of 20,000 bytes - that does not mean that you have to set the buffer size to 20,000 bytes!

In fact, I think it would be quite unusual to have such a large buffer!
As FFT explained, you would usually use a smaller buffer, and send your data in “chunks”…

Hello Awneil,

Thanks for the reply.

Actually, my buffer is a structure buffer. just i’m trying to dump my structure buffer into ftp.

I mean, i called the below function to set the emmision buffer size.

ret = wip_setOpts(ftp_WipHandle, WIP_COPT_SND_BUFSIZE, 20000,WIP_COPT_SND_LOWAT,1000, WIP_COPT_END );

This returns error as “WIP_CERR_NOT_SUPPORTED”. I could not understand, what probelm is there?

Could you please clearfy me.

Thanks.

is ftp_wipHandle the session channel, or the file transfer channel? The former doesn’t support TCP settings such as buffer dimensionning.

Hello fft,

I here by posted a part of the code which im trying.

wip_channel_t ftp_WipHandle, ftp_WipDataHandle; 

void Connect_FTP( void ) {	

	char test[100];	
			
	ftp_WipHandle = wip_FTPCreateOpts( ftpserv, ftp_SessionHandler, NULL, WIP_COPT_USER, ftpun, WIP_COPT_PASSWORD, ftpPwd, WIP_COPT_PEER_PORT, 21,WIP_COPT_END); 
	if(ftp_WipHandle==NULL) {
		PRI_CMD("WIP_FTP_CREATE_FAIL \r\n");
	}
	else {
		PRI_CMD("WIP_FTP_CREATE_SUCCESS \r\n");
	}


}

void ftp_SessionHandler( wip_event_t *ev, void *ctx ) {
	
	char tempbuf[100];				// character buffer to be used debug.
	int ret;

	PRI_CMD("\r\n FTP_SESSION_HANDLER-->");
	switch( ev->kind )
	{   
	case WIP_CEV_OPEN:			
	    PRI_CMD("WIP_CEV_OPEN \r\n");
 	   ret = wip_setOpts(ftp_WipHandle, WIP_COPT_SND_BUFSIZE, 20000,WIP_COPT_SND_LOWAT,1000, WIP_COPT_END ); 

	    if( ret == 0 ) {
	    PRI_CMD("WIP_SET_OPTIONS_SUCCESS \r\n");
	} 
	else if ( ret == WIP_CERR_NOT_SUPPORTED ) {
	     PRI_CMD("WIP_SET_OPTIONS_FAIL-> NOT SUPPORTED \r\n");
	} 
	else {
	     PRI_CMD("WIP_SET_OPTIONS_FAIL-> INVALID \r\n");
	}
	ftp_WipDataHandle = wip_putFile( ftp_WipHandle, filename, ftp_DataHandler, NULL);
	if(ftp_WipDataHandle==NULL) {
	    PRI_CMD("WIP_PUT_FILE_FAIL  \r\n");
	}
	else {
	    PRI_CMD("WIP_PUT_FILE_SUCCESS \r\n");
	} 
	break;

	case WIP_CEV_DONE:
	    PRI_CMD("CEV_DONE\r\n");			
	break;
		
	case WIP_CEV_PEER_CLOSE:
	    PRI_CMD("CEV_PEER_CLOSE\r\n");
	    wip_close( ftp_WipHandle);
	break;

	case WIP_CEV_ERROR:
                     PRI_CMD("CEV ERROR\r\n");
   	break;
		
	default:
	      PRI_CMD("DEFAULT ERROR\r\n");
	break;
	}
}

Thanks,

ftp_WipDataHandle does support buffer size setting, but ftp_WipHandle does not.

Hi fft,

Thanks a lot.

Now buffer size configured as 26000 and i have written into FTP. It’s working fine.

Thanks,

Hi fft,

I am facing another problem in the same code.

I have set the send buffer size as 26,000bytes.

it was success.

Then i have to send a buffer which has upto 13,500 bytes of data. It’s woking fine and data transfered into FTP.

Now i’m trying to send a buffer which has 20,000 bytes of data. But write function fails and return some negative value.

What is the problem that im facing? could you Please help me to find out…

Tahnks,

  • what’s the negative value? (check return codes in wip_channel.h, type wip_error_t)
  • if you send your 20K just after your 13K, your issue is that 33K > 20K ==> increase buffer size or use WIP_CEV_WRITE messages. You might want to look at WIP_COPT_SND_LOWAT to control the moment at which the message is sent.
  • if you send them on different sockets, check the total amount of buffers allocated to the whole IP stack. If not suitable, tune it either with AT+WIPS or with wip_netInitOpts() depending on your WIP version (check the manual for details).

Hi fft,

The error number -992 return.this means, “NO MORE TCP BUFFERS AVAILABLE”.

How i can send more data in a sigle buffer?.

Thanks,

for wip versions <= 3, look at wip_netInitOpts() parameters. For versions <= 4, look at AT+WIPS AT command.

Hi fft,

I am using WIP version 2.00.31.

I think, the buffer size that im trying to write too.

Now i want to know, The maximum size of the send buffer size.

Thanks,