A
Aditya
Hi
I am using recv() from socket.h in one of my TCP-client projects.
The problem is that the buffer variable in recv(socketDescriptor,
buffer, flags) points to some stray location and when the incoming
string is filled into it, there are trailing junk characters also.
The code portion refering to it is somewhat like:
int rcvStatus;
char *buffer;
rcvStatus = recv(socketDescriptor, buffer, flags);
std::cout<< buffer << std::endl;
If I initialize the buffer variable to NULL or "0", the recv() returns
-1, that is it doesn't accept the incoming string.
So, Please help me to clean the buffer variable, before it is being
filled with the incoming string.
Thanks
Aditya
I am using recv() from socket.h in one of my TCP-client projects.
The problem is that the buffer variable in recv(socketDescriptor,
buffer, flags) points to some stray location and when the incoming
string is filled into it, there are trailing junk characters also.
The code portion refering to it is somewhat like:
int rcvStatus;
char *buffer;
rcvStatus = recv(socketDescriptor, buffer, flags);
std::cout<< buffer << std::endl;
If I initialize the buffer variable to NULL or "0", the recv() returns
-1, that is it doesn't accept the incoming string.
So, Please help me to clean the buffer variable, before it is being
filled with the incoming string.
Thanks
Aditya