Code:
recv(control_soc, &data, sizeof(char) * BUFFER, NULL);
recv() is: recv(int socket, void *buffer, size_t len, int flags); Using that:
1) &data can be just "data" (data is a char array).
2) sizeof(char) * BUFFER is correct, syntax-wise, but you won't have room to insert a null terminator should you need one.
3) The last argument is an integer. You want to pass 0, not NULL. (Majority of your errors are this)
Code:
data[errorlevel] = NULL;
First, data is a char array. You want to set it to either 0 or '\0', but not NULL. (NULL is for pointers.) Finally, you say:
Code:
errorlevel = recv(control_soc, data, sizeof(char) * BUFFER, NULL);
data[errorlevel] = NULL;
What if recv fills your buffer completely? recv() will return BUFFER * sizeof(char), and then you use that as an index, which is out of bounds. Basically re-interates my second suggestion above.
Hope that helps. (Edit: Good indentation is a boon to error-seekers.)