2 Replies Latest reply on Jun 3, 2013 5:29 PM by nikvh
      • 1. Re: TCP streaming
        wiced_tcp_send_buffer() was the precursor for the wiced_tcp_stream API and is currently only used by the http protocol library although its use could be replaced with a wiced_tcp_stream_write + flush. The function still exists to offer a simple method of transmitting a large block of data without worrying about splitting it up into separate packets.

         

         

        The TCP stream API was created to simplify the transmission of data that is generated in a piecemeal fashion. The HTTP server daemon was the main reason for its creation. Reception of data, however, does not occur in the same manner and so there is no wiced_tcp_stream_read() function. The TCP socket has either received a packet or it has not. If a packet has been received it needs to be processed and then freed as soon as possible to ensure optimal packet buffer utilization.

         

         

        If an application or library requires more data than is provided by a single packet it is the responsibility of that application or library to create temporary storage and copy the data out of the packet.
        • 2. Re: TCP streaming
          Reception of data, however, does not occur in the same manner and so there is no wiced_tcp_stream_read() function. The TCP socket has either received a packet or it has not. If a packet has been received it needs to be processed and then freed as soon as possible to ensure optimal packet buffer utilization.

           

           

          Stream write operation keeps some state in the stream struct (outgoing packet), read could be implemented similarly. Keep receiving packets in a loop (wiced_tcp_receive is blocking), read the data from the packets into a destination buffer until its full or until EOF, store (in the stream struct) one packet + current offset if partially read. All packets are immediately freed, except the last partially read one (no worse than stream write).
          • 3. Re: TCP streaming
            What you have suggested is actually implemented in other internal parts of WICED and could be added to the TCP stream API.

             

            Ill add it to the TODO list