Thread: Web Client
View Single Post
Old Oct 1st, 2006, 1:21 AM   #3
climbnorth
Newbie
 
Join Date: Oct 2006
Posts: 16
Rep Power: 0 climbnorth is on a distinguished road
Look at this page for using recv, should help:

http://www.opengroup.org/onlinepubs/...ions/recv.html

Realize that recv returns a value. That value is how many bytes were read.
So read until it stops receiving bytes. Remember, it returns negative if there was an error, so handle that too.

This operation will block- which means, it will hang your application. This is not so great if your application wants to do other stuff while waiting for this data. To solve, you should put this into a seperate thread (unless your app doesn't do anything until it gets the data- in which case its ok BUT if this is GUI app, use thread or GUI will hang).

Also, you shouldn't put the declaration of your pointer inside the loop.
Also, you should consider not new/delete over and over in the loop. Instead, write to a buffer and reallocate the size as needed. There is a function called realloc that can help.


--
climbnorth is offline   Reply With Quote