jeudi 28 octobre 2021

C++ Socket recv() always returns 0

1) Does work:

char blockSize[4];
int r = recv(socket, blockSize, 4, 0);


2) Does not work. It always returns zero:

size_t blockSize = 0;
int r = recv(socket, (char*)blockSize, 4, 0);

Why does the code in paragraph two instantly return 0?

It's not a major problem, I know how to convert the char array back to a size_t. But I just want to know why it's not working.

Aucun commentaire:

Enregistrer un commentaire