Question: What do these 2 functions do? Please go into detail, thank you int writeSock(int sock, char* buf, size_t len) { ssize_t byteswrote = 0; ssize_t

What do these 2 functions do? Please go into detail, thank you

int writeSock(int sock, char* buf, size_t len) { ssize_t byteswrote = 0; ssize_t ret = 0;

while (byteswrote < len) { ret = send(sock, buf + byteswrote, len - byteswrote, 0);

if (ret < 0) { return -1; }

if (ret == 0) { break; }

byteswrote += ret; }

return byteswrote; }

int readSock(int sock, char* buf, size_t len) { ssize_t ret = 0; ssize_t bytesread = 0;

while (bytesread < len) { ret = recv(sock, buf + bytesread, len - bytesread, 0);

if (ret == 0) { break; }

if (ret < 0) { return -1; }

bytesread += ret; }

return bytesread; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!