Audiovox P965 Arkusz Danych Strona 64

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 280
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 63
API in C using winsock
61
DEBUG ? printSentence (&stReadSentence) : 0;
if (stReadSentence.iReturnValue == DONE)
{
return 1;
}
else
{
return 0;
}
}
/********************************************************************
* Encode message length and write it out to the socket
********************************************************************/
void writeLen(int fdSock, int iLen)
{
char *cEncodedLength; // encoded length to send to the api socket
char *cLength; // exactly what is in memory at &iLen integer
cLength = calloc(sizeof(int), 1);
cEncodedLength = calloc(sizeof(int), 1);
// set cLength address to be same as iLen
cLength = (char *)&iLen;
DEBUG ? printf("length of word is %d\n", iLen) : 0;
// write 1 byte
if (iLen < 0x80)
{
cEncodedLength[0] = (char)iLen;
send (fdSock, cEncodedLength, 1, 0);
}
// write 2 bytes
else if (iLen < 0x4000)
{
DEBUG ? printf("iLen < 0x4000.\n") : 0;
if (iLittleEndian)
{
cEncodedLength[0] = cLength[1] | 0x80;
cEncodedLength[1] = cLength[0];
}
Przeglądanie stron 63
1 2 ... 59 60 61 62 63 64 65 66 67 68 69 ... 279 280

Komentarze do niniejszej Instrukcji

Brak uwag