Datasheet
API in C using winsock
66
}
iLen = (int *)cLength;
}
// assume 1-byte encoded length...same on both LE and BE systems
else
{
DEBUG ? printf("1-byte encoded length\n") : 0;
iLen = malloc(sizeof(int));
*iLen = (int)cFirstChar;
}
return *iLen;
}
/********************************************************************
* Read a word from the socket
* The word that was read is returned as a string
********************************************************************/
char *readWord(int fdSock)
{
int iLen = readLen(fdSock);
int iBytesToRead = 0;
int iBytesRead = 0;
char *szWord;
char *szRetWord;
char *szTmpWord;
DEBUG ? printf("readWord iLen=%x\n", iLen) : 0;
if (iLen > 0)
{
// allocate memory for strings
szRetWord = calloc(sizeof(char), iLen + 1);
szTmpWord = calloc(sizeof(char), 1024 + 1);
while (iLen != 0)
{
// determine number of bytes to read this time around
// lesser of 1024 or the number of byes left to read
// in this word
iBytesToRead = iLen > 1024 ? 1024 : iLen;










