I have some networking code ported from Solaris to Cocoa (OS X
10.4.8) that works, almost. I'm using writev() and readv() with TCP/
IP sockets to transmit datasets of size 230586 bytes each over the
internet. The problem is, I don't receive all the bytes in a single
readv() call; on OS X I have to call readv() multiple times to get
all the data.
Sender code snippet:
int byteswritten;
char *outbuf = < pointer to my data >;
size_t buflen = 230586;
The single writev() call returns with a status of 230586, so it
writes all the data in one call. But the receive loop reads 114324
bytes, then 82076, and finally 34186 bytes. The next time I might
read 48996, 97992, 48996, and 34602 bytes. Etc. I'm no expert at
this, so I'm probably not doing this right, but why is the loop
necessary to receive all the data?
Or is there a preferred Cocoa way to accomplish sending large buffers?