sillv0r
October 12th, 2008, 01:22 AM
Howdy,
I have a quick question about memory management when sending data over a socket. (I'm using blocking sockets in cpp. If any additional information is needed please ask.)
I think I merely lack an understanding of the way this kind of thing is supposed to work. So any constructive criticism is welcome.
Consider the following statement:
send(sockfd, buffer, length, 0);
My problem is that buffer is a dynamically allocated array.
I'm not sure about how to release the memory taken up by buffer at the completion of the send call.
* At the completion of the call to send, has all the data in buffer been "placed on the line?"
- If it has, then I figure memory used by buffer can be safely released--or can it?
- If it hasn't, I don't believe that the socket library will release the memory for me--or does it?
Thoughts? Questions?
I have a quick question about memory management when sending data over a socket. (I'm using blocking sockets in cpp. If any additional information is needed please ask.)
I think I merely lack an understanding of the way this kind of thing is supposed to work. So any constructive criticism is welcome.
Consider the following statement:
send(sockfd, buffer, length, 0);
My problem is that buffer is a dynamically allocated array.
I'm not sure about how to release the memory taken up by buffer at the completion of the send call.
* At the completion of the call to send, has all the data in buffer been "placed on the line?"
- If it has, then I figure memory used by buffer can be safely released--or can it?
- If it hasn't, I don't believe that the socket library will release the memory for me--or does it?
Thoughts? Questions?