[squeak-dev] Check syntactically valid code

Levente Uzonyi leves at caesar.elte.hu
Thu Apr 27 17:26:29 UTC 2017


Hi Ian,

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.
- 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.
- 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.

Levente

On Thu, 27 Apr 2017, Ian Trudel wrote:

> Hello Levente,
> 
> I implemented a small syntax server based on your recommendation. The code commented in SyntaxServer>>process: is working but requires the client to reconnect each time it wants to send source code to be validated, which is time consuming. Reusing the connection would
> be faster but the code here is not working. Any hint?
> 
> Best regards,
> Ian
> 
>


More information about the Squeak-dev mailing list