protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Cannot use "file descriptor" abstraction for sockets under Windows

Open chacha21 opened this issue 1 year ago • 0 comments

Google protobuf offers the "file descriptor" abstraction to read/write through a FileInputStream.

Unfortunately, while under Unix those file descriptor are perfectly compatible with TCP sockets, it is not the case under Windows.

Winsock is based on a SOCKET type which is not a file descriptor (https://learn.microsoft.com/en-us/windows/win32/winsock/socket-data-type-2)

Trying to force cast the windows SOCKET to an int leads to a crash because the ::_read and ::_write functions won't work.

Could it be possible to add a "native socket" abstraction for Google protobufs that would be able to use dedicated winsock send/recv instead of _read/_write ?

I understand that I can do that myself by creating such a derived class, on my "server" side. But it would be nice to get an "official" support, so that under Windows, a "client user" would not need any custom code, only the proto file, to create his own client software.

chacha21 avatar Jun 24 '24 16:06 chacha21