laurent.orseau
2022-3-16 18:33:05

read on the server is blocking when the input is small even after a (flush-output) from the client side. I can’t remember what’s the magic bit to make it read anyway. Any clue?


sorawee
2022-3-16 18:34:41

Can you close the port?


laurent.orseau
2022-3-16 18:34:46

nope


laurent.orseau
2022-3-16 18:35:12

If I do read-line instead, it works though (but then I need to read from the string)


sorawee
2022-3-16 18:36:01

Can the client send a newline?


laurent.orseau
2022-3-16 18:36:08

It already does


laurent.orseau
2022-3-16 18:36:17

(otherwise read-line wouldn’t work)


sorawee
2022-3-16 18:36:52

Interesting


sorawee
2022-3-16 18:37:03

What’s the content that is being read / sent?


laurent.orseau
2022-3-16 18:37:18

s-exp


sorawee
2022-3-16 18:37:22

Also, does this always happen? Or just only for some s-exp?


laurent.orseau
2022-3-16 18:37:47

So basically this works: (with-input-from-string (read-line) read), but not a mere read


laurent.orseau
2022-3-16 18:38:05

Possibly the issue is with symbols


laurent.orseau
2022-3-16 18:38:14

though I’m not sure


greg
2022-3-16 18:40:43

What if you do (file-stream-buffer-mode the-tcp-input-port 'none)?


laurent.orseau
2022-3-16 18:45:34

That was a good idea, but it doesn’t seem to work


sorawee
2022-3-16 18:48:27

Do you know what are the last few characters that are being read?


laurent.orseau
2022-3-16 18:48:50

nothing has been read yet


laurent.orseau
2022-3-16 18:49:05

it’s blocking on the first things


laurent.orseau
2022-3-16 18:53:36

laurent.orseau
2022-3-16 18:54:37

apart maybe from using fasl


mflatt
2022-3-16 18:56:13

Is the text of the line something you can share?


laurent.orseau
2022-3-16 18:56:45

'ready


sorawee
2022-3-16 18:57:12

with newline at the end, right?


laurent.orseau
2022-3-16 18:57:15

(writeln 'ready) (flush-output)


laurent.orseau
2022-3-16 18:58:07

laurent.orseau
2022-3-16 18:59:37

This also blocks: (writeln '(ready)) (flush-output)


mflatt
2022-3-16 18:59:49

And (with-input-from-string (read-line) read) returns 'ready?


laurent.orseau
2022-3-16 18:59:55

yes


laurent.orseau
2022-3-16 19:01:49

(with the slight difference that I’m reading from an input port, piped by process*/ports)


mflatt
2022-3-16 19:05:21

It seems likely that I’m missing something about the context. The only case I can think of where read-line would return and read wouldn’t on the same input port are cases where read would produce eof or it would error trying to read the line by itself.


laurent.orseau
2022-3-16 19:06:37

But then (with-input-from-string (read-line) read) wouldn’t work either I guess


laurent.orseau
2022-3-16 19:07:50

A long time ago, there was a bug in DrRacket (on my machine at least) where entering 'a in the interaction window didn’t output anything, then entering a number made both be read. Maybe unrelated though.


laurent.orseau
2022-3-16 19:10:00

Could be a linux problem. I’ll try to write a MWE tomorrow