`Socket.receive` providing arbitrary packet sizes and hanging without sending EOF

Ali Çehreli acehreli at yahoo.com
Sun Dec 17 02:01:39 UTC 2017


On 12/16/2017 05:21 PM, Unazed Spectaculum wrote:

 > 1) Starting program
 > unazed at unazed  /home/d/storage-server  dmd -debug -run app.d

Although I don't normally use the -run switch, as expected, it works 
with -run as well. (More below.)

 > Listening: 0.0.0.0:6969
 >
 > 2) telnet to the server
 >   unazed at unazed  ~  telnet 0.0.0.0 6969
 > Trying 0.0.0.0...
 > Connected to 0.0.0.0.
 > Escape character is '^]'.

Note that line! ;)

 >
 > 3) paste '{"filename":"/tmp/foo","method":"bar"}'

Please also press Enter after that. I don't know what code is at fault 
but the json parser was not happy without that newline at the end.

 >   unazed at unazed  /home/d/storage-server  dmd -debug -run app.d
 > Listening: 0.0.0.0:6969
 > Client: 127.0.0.1:55014
 > Chunk 0
 > [123, 34, 102, 105, 108, 101, 110, 97, 109, 101, 34, 58, 34, 47, 116,
 > 109, 112, 47, 102, 111, 111, 34, 44, 34, 109, 101, 116, 104, 111, 100,
 > 34, 58, 34, 98, 97, 114, 34, 125, 13, 10]
 > Chunk 1
 > [pause]

Same here...

 > 4-5) press ESC + CTRL+D (I'm on Linux)

Aha! That's the problem! You should enter the "Escape character", which 
is ^] as telnet indicates. You should press Ctrl-] (stay away from the 
ESC key). Otherwise, you're injecting an ESC character to the 
communication stream. (The 27 below.)

By the way, I'm on Linux as well! :) (Mint, Ubuntu based.)

And finally, press Ctrl-D to end the stream. It really works:

[...]
Chunk 1
Exiting "receiveAll"
{"filename":"/tmp/foo","method":"bar"}
[...]

Ali



More information about the Digitalmars-d-learn mailing list