Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make the MC protocol work on top of STREAM sockets
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 4 Apr 2023 21:45:27 +0000 (23:45 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 4 Apr 2023 22:05:45 +0000 (00:05 +0200)
commit159bd689add924b1387a9caa0a095ba77a716aba
tree6dfa9d9c624c32505da4905f619b98d8895703c2
parent5182f92364f7f00460daa81b3f7988bd25ac50dc
Make the MC protocol work on top of STREAM sockets

MacOSX does not have AF_UNIX + SOCK_SEQPACKET so we need SOCK_STREAM
for that architecture. I'll make it SEQPACKET on Linux+FreeBSD and
STREAM on Mac in the next commit, but I wanted to code and debug the
SOCK_STREAM version locally.

The problem with the SOCK_STREAM version is that messages are not
segmented anymore: each recv() gets everything that got posted on the
socket already, so I have to implement a buffer in which I can
reinject the extraneous bytes received, so that they can be used in
the next recv(). The real fun begins when I have half of the expected
message in buffer and the other half must be taken from the network.

Or even better: the second half was not posted yet so reading from the
network is blocking for ever. This can happen when I receive any
message in a 512-bytes buffer, but I already had a full but shorter
message in buffer. I have to try reading from the socket with the
DONT_WAIT flag, detect that there is nothing to read, and use the
buffer content only.
src/mc/api/RemoteApp.cpp
src/mc/remote/AppSide.cpp
src/mc/remote/Channel.cpp
src/mc/remote/Channel.hpp
src/mc/remote/CheckerSide.cpp
src/mc/remote/CheckerSide.hpp
src/mc/remote/mc_protocol.h