Your whole approach is wrong.
(1) As I pointed out in my first post and as Philip Nicoletti said, when you call:
Code:
string(buffer,from,until);
there's no template that takes char* pointer followed by an int, so your code is technically truncated to:
and 'buffer' is treated as a NULL terminated string, so if it isn't it can easily cause a memory fault.
(2) Transmitting data through a socket is not done as a continuous stream of char's. You need to create a custom type, put it into a header file shared by both sender and receiver and validate it before you attempt reading a 'char' string from it:
Code:
struct MY_SOCKET_DATA{
DWORD dwStructID; //Special ID to identify this struct
int ncbSzTotal; //Total size of transmitted data in bytes
int nSzString; //Size of string in char's
char String[0]; //Beginning of transmitted ANSI string
};
//Validation
MY_SOCKET_DATA* pSD = (MY_SOCKET_DATA*)pSocketRawData;
if(pSD->dwStructID == UNIQUE_TRANSMISSION_ID &&
pSD->ncbSzTotal == ncbSocketRawDataLength)
{
//Now you can read 'pSD->nSzString' number of chars from 'pSD->String'
}
(3) And use debugger to see what's going on with your code.