2017-04-27 13:26 GMT-04:00 Levente Uzonyi <leves@caesar.elte.hu>:
Hi Ian,

Hi again,
 
I see a few issues with the code you attached:
- #receiveData will only read at most 2000 bytes and will get the content of one or maybe more TCP packets. But if you have larger packets enabled on your network, it'll only read a partial packet. I suggest you use SocketStream, because you don't want to process packets but a stream of data.

SocketStream seems like a good idea.
 
- if you want to handle multiple requests through a single TCP connection, you should come up with a protocol to separate the different calls, so that you know where a request starts and ends. For example, you could just write 2 bytes, the length of the source string and then the source string itself. Or you could use Smalltalk's chunk format. Or whatever you come up with that fits your needs.

Yes, I was thinking about sending length of the source code first. That would certainly allow SyntaxServer to know how many bytes to expect.

- locking is unnecessary for a single variable. As long as there's no real message send (non-failing primitives are not real sends) or backwards jump (loop) in your code, it'll be thread safe.

It was actually in a Pharo Sockets tutorial by Noury Bouraqadi and Luc Fabresse.

Thanks for your feedback!

Ian