Socket closes after sending 2KB of data


I am reading some data from a device then send it via GPRS.
If the data is less than 2KB, the whole data is transferred successfully.
However, when the data is bigger than 2KB, after sending the first 2KB of data, the socket closes.
What do you think is the problem?
Did anyone experienced this before?


what set of characters when sent can make the socket close?


Are you basing your code on the WIP FTP sample? If so, the code in the WIP_CEV_WRITE event is not quite right.

wip_write() only appears to load your data in the the channel/socket TX buffer. IT DOES NOT push the data out the buffer. So when wip_write() returns a value that indicates all your data has been sent, it actually hasn’t been TX’d to the client yet - only queued in the buffer to go in the next TCP packet.

The WIP FTP sample shows that after wip_write() returns that all your data has been sent, you need to call wip_close(). THIS IS NOT CORRECT. wip_close() will immediately CLOSE the channel and dump any pending data in the TX buffer…which is why you’re only seeing the first 2k of your data being transmitted.

Instead of calling wip_close(), call wip_shutdown() with the appropriate values to shutdown the write operation. This will wait until the TX buffer is empty before closing the connection and waiting for read data (if required).

I’ve just been through this for a client - and the documentation is not all that flash, and the samples are obscure.

Let us know how you get on.

ciao, Dave