Hi Forum,
I am a newbie programmer.I have a problem as goes below,
void SockSend()
{
char *sendbuf;
int sendsize; /* send data size(variable size)*/
int iPos = 0, iTotSize;
char hdr;
char *data = "ABCDEFGHIJKLMNO"; /* its just example, data can be any thing */
sendsize = strlen(data);
hdr = '\0'; /* header character */
sendbuf = (char*)malloc(sendsize + 2);
sendbuf[iPos] = hdr;
iPos++;
strncpy(sendbuf + iPos, data, 15);
iPos += sendsize;
sendbuf[iPos] = '\0'; /* append null at end of string*/
iTotSize = strlen(sendbuf);
send(sockid, sendbuf, iTotSize, 0);
}
As In the above code, i need to send the data with header character attached. if header ascii character is between 1h - ffh other than 0h works properly. I know that if null is added to string it consider as end of string. But i need to send NULL character with data through the socket. Can anybody please help me how to solve this problem.
Thank you in advance