Op 08-12-2021 om 12:40 schreef Tomas Kalibera:
On 12/8/21 12:20 PM, Ben Engbers wrote:
Op 07-12-2021 om 23:49 schreef Ben Engbers:
The new code, which now uses a non-blocking socket, takes less than 4
seconds to execute the 53 tests. Compared to the 120 seconds when
using a blocking socket, this was worth the effort.
Ok, this confirms there is a race condition, but the next step should be
removing it, so that it works reliably. Actually, one way to test that
such programs are race-free is to actually on purpose insert sleeps at
various locations - the programs then should still work.
I am not able to give more specific advice based on the code snippet you
sent yesterday, but in principle, you can use socketSelect() to wait for
the connection to become ready to be read from. In either case, there
needs to be some way to tell whether the received data is complete.
Either you know the length, or there is some special mark in the data,
there has to be something.
writeBin(auth, private$conn)
Sys.sleep(.1)
Accepted <- readBin(conn, what = "raw", n = 1) == 0
I checked in the debugger that auth has the correct length. And
readBin(conn, what = "raw", n = 1) should return exactly 1 byte (either
0x00 or 0x01.
You say that socketSelect() can be used to wait for the connection to
become ready.
How? The only option I see is a "no-delay". Should I set this to FALSE?
I tried adding 'options = getOption(c("no-delay = <value>"))' when
creating the socketConnection. In the tesfile (see below) value TRUE or
FALSE were both accepted. In the package, createSocket still failed.
If you need more help from people on the list, it might be better to
send a small, but full complete example, so also with a server, so that
it is something people could run and reproduce.
The server can be downloaded from https://basex.org/download/. After
unzipping it can be started with 'basexserver &'.
I have attached a testfile.
Ben
Best
Tomas
______________________________________________
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel