Why is there no 64-bit API for winsock?

Viewed 1094

Calls such as send() and sendto() in the Winsock API take a primitive int to dictate the size of their buffer parameters. This obviously places a 32-bit limit on the maximum size buffer that may be sent.

Why is this? Is there a 64-bit Winsock2 API available that might use a more appropriate size type (e.g. size_t)?

On Linux similar calls use the size_t type for defining sizes.

1 Answers

There is no need for a function with larger size, actually the type could be short and still it won’t be a problem.

Sockets don’t send messages, they just transfer bytes. When you call send() the data may not get received in one chunk at the recv() call. You have to implement logic when receiving bytes to know if you got it all or not and call recv() again if not. So if you wanna send something larger than can be placed in an int? Just make multiple calls to send(). If your recv() code can’t handle that, it’s a bug, because it should.

Related